diff --git a/backend/src/routes/parents/dto/pending-family.dto.ts b/backend/src/routes/parents/dto/pending-family.dto.ts index 86389b2..68dd50c 100644 --- a/backend/src/routes/parents/dto/pending-family.dto.ts +++ b/backend/src/routes/parents/dto/pending-family.dto.ts @@ -7,6 +7,12 @@ export class ParentPendingSummaryDto { @ApiProperty() email: string; + @ApiPropertyOptional({ nullable: true }) + nom?: string | null; + + @ApiPropertyOptional({ nullable: true }) + prenom?: string | null; + @ApiPropertyOptional({ nullable: true }) telephone?: string | null; @@ -18,7 +24,10 @@ export class ParentPendingSummaryDto { } export class PendingFamilyDto { - @ApiProperty({ example: 'Famille Dupont', description: 'Libellé affiché pour la famille' }) + @ApiProperty({ + example: 'MARTIN Claire - MARTIN Thomas', + description: 'Libellé affiché : NOM Prénom (séparés par « - » si co-parent)', + }) libelle: string; @ApiProperty({ diff --git a/backend/src/routes/parents/parents.service.ts b/backend/src/routes/parents/parents.service.ts index 15c0581..77dc3c6 100644 --- a/backend/src/routes/parents/parents.service.ts +++ b/backend/src/routes/parents/parents.service.ts @@ -251,7 +251,15 @@ export class ParentsService { SELECT id, (MIN(rep::text))::uuid AS rep FROM rec GROUP BY id ) SELECT - 'Famille ' || string_agg(u.nom, ' - ' ORDER BY u.nom, u.prenom) AS libelle, + string_agg( + UPPER(TRIM(u.nom)) + || CASE + WHEN u.prenom IS NOT NULL AND TRIM(u.prenom) <> '' + THEN ' ' || INITCAP(TRIM(u.prenom)) + ELSE '' + END, + ' - ' ORDER BY u.nom, u.prenom, u.id + ) AS libelle, array_agg(p.id_utilisateur ORDER BY u.nom, u.prenom, u.id) AS "parentIds", (array_agg(p.numero_dossier))[1] AS numero_dossier, MIN(u.cree_le) AS date_soumission, @@ -267,6 +275,8 @@ export class ParentsService { json_build_object( 'id', u.id::text, 'email', u.email, + 'nom', u.nom, + 'prenom', u.prenom, 'telephone', u.telephone, 'code_postal', u.code_postal, 'ville', u.ville @@ -317,11 +327,21 @@ export class ParentsService { return []; } - private normalizeParents(parents: unknown): { id: string; email: string; telephone: string | null; code_postal: string | null; ville: string | null }[] { + private normalizeParents(parents: unknown): { + id: string; + email: string; + nom: string | null; + prenom: string | null; + telephone: string | null; + code_postal: string | null; + ville: string | null; + }[] { if (Array.isArray(parents)) { return parents.map((p: any) => ({ id: String(p?.id ?? ''), email: String(p?.email ?? ''), + nom: p?.nom != null ? String(p.nom) : null, + prenom: p?.prenom != null ? String(p.prenom) : null, telephone: p?.telephone != null ? String(p.telephone) : null, code_postal: p?.code_postal != null ? String(p.code_postal) : null, ville: p?.ville != null ? String(p.ville) : null,