diff --git a/backend/src/routes/auth/auth.service.ts b/backend/src/routes/auth/auth.service.ts index 308bb81..e31085e 100644 --- a/backend/src/routes/auth/auth.service.ts +++ b/backend/src/routes/auth/auth.service.ts @@ -552,7 +552,8 @@ export class AuthService { : undefined; enfant.photo_url = urlPhoto || undefined; enfant.status = enfantDto.date_naissance ? StatutEnfantType.SANS_GARDE : StatutEnfantType.A_NAITRE; - enfant.consent_photo = false; + enfant.consent_photo = !!enfantDto.consent_photo; + enfant.consent_photo_at = enfant.consent_photo ? new Date() : null!; enfant.is_multiple = enfantDto.grossesse_multiple || false; const enfantEnregistre = await manager.save(Children, enfant); @@ -1074,6 +1075,12 @@ export class AuthService { if (enfantDto.grossesse_multiple !== undefined) { enfant.is_multiple = enfantDto.grossesse_multiple; } + if (enfantDto.consent_photo !== undefined) { + enfant.consent_photo = !!enfantDto.consent_photo; + enfant.consent_photo_at = enfant.consent_photo + ? new Date() + : null!; + } if (enfantDto.photo_base64 && enfantDto.photo_filename) { enfant.photo_url = await this.sauvegarderPhotoDepuisBase64( diff --git a/backend/src/routes/auth/dto/enfant-inscription.dto.ts b/backend/src/routes/auth/dto/enfant-inscription.dto.ts index 9ee120c..dce0f51 100644 --- a/backend/src/routes/auth/dto/enfant-inscription.dto.ts +++ b/backend/src/routes/auth/dto/enfant-inscription.dto.ts @@ -59,5 +59,14 @@ export class EnfantInscriptionDto { @IsOptional() @IsBoolean() grossesse_multiple?: boolean; + + @ApiProperty({ + example: true, + required: false, + description: 'Consentement affichage / stockage photo (colonne enfants.consentement_photo)', + }) + @IsOptional() + @IsBoolean() + consent_photo?: boolean; } diff --git a/backend/src/routes/enfants/enfants.service.ts b/backend/src/routes/enfants/enfants.service.ts index e4b46c4..7f4552c 100644 --- a/backend/src/routes/enfants/enfants.service.ts +++ b/backend/src/routes/enfants/enfants.service.ts @@ -120,7 +120,13 @@ export class EnfantsService { const child = await this.childrenRepository.findOne({ where: { id } }); if (!child) throw new NotFoundException('Enfant introuvable'); - await this.childrenRepository.update(id, dto); + const patch: Partial = { ...dto } as Partial; + if (dto.consent_photo !== undefined) { + patch.consent_photo = dto.consent_photo; + patch.consent_photo_at = dto.consent_photo ? new Date() : null!; + } + + await this.childrenRepository.update(id, patch); return this.findOne(id, currentUser); } diff --git a/frontend/lib/utils/parent_registration_payload.dart b/frontend/lib/utils/parent_registration_payload.dart index 70a9459..467cd35 100644 --- a/frontend/lib/utils/parent_registration_payload.dart +++ b/frontend/lib/utils/parent_registration_payload.dart @@ -167,6 +167,7 @@ class ParentRegistrationPayload { final map = { 'genre': apiGenres.contains(c.genre) ? c.genre : 'Autre', 'grossesse_multiple': c.multipleBirth, + 'consent_photo': c.photoConsent, }; final prenom = c.firstName.trim(); diff --git a/frontend/lib/utils/reprise_mapper.dart b/frontend/lib/utils/reprise_mapper.dart index 53c285b..f965e1a 100644 --- a/frontend/lib/utils/reprise_mapper.dart +++ b/frontend/lib/utils/reprise_mapper.dart @@ -44,8 +44,8 @@ class RepriseMapper { lastName: e.lastName ?? '', dob: dob, genre: e.gender ?? '', - // Inscription initiale exigeait la coche pour envoyer la photo ; le back - // ne persistait pas toujours consent_photo — on pré-coche si photo en base. + // Legacy : dossiers inscrits avant #144 avaient consent_photo=false malgré une photo. + // On pré-coche encore si photo en base pour ne pas bloquer la reprise. photoConsent: e.consentPhoto || hasPhoto, multipleBirth: e.estMultiple, isUnbornChild: isUnborn,