feat(#112): aligner reprise front sur dossier complet GET/PATCH

Préremplit parents, enfants, motivation et fiche AM depuis reprise-dossier
et envoie le body PATCH complet (co-parent, enfants par id, champs pro AM).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 16:46:51 +02:00
co-authored by Cursor
parent 25c10c885a
commit f300505225
11 changed files with 439 additions and 92 deletions
+26 -21
View File
@@ -43,6 +43,10 @@ class ChildData {
/// Octets de la photo (fiable à lenvoi API ; [imageFile] peut être absent sur le web).
Uint8List? imageBytes;
CardColorVertical cardColor; // Nouveau champ pour la couleur de la carte
/// UUID enfant en base (reprise #112) — requis pour PATCH reprise-resoumettre.
String? repriseChildId;
/// Photo déjà stockée (affichage reprise sans re-upload).
String? existingPhotoUrl;
ChildData({
this.firstName = '',
@@ -55,6 +59,8 @@ class ChildData {
this.imageFile,
this.imageBytes,
required this.cardColor, // Rendre requis dans le constructeur
this.repriseChildId,
this.existingPhotoUrl,
});
ChildData copyWith({
@@ -68,6 +74,8 @@ class ChildData {
Object? imageFile = _unsetImage,
Object? imageBytes = _unsetImageBytes,
CardColorVertical? cardColor,
String? repriseChildId,
String? existingPhotoUrl,
}) {
return ChildData(
firstName: firstName ?? this.firstName,
@@ -81,6 +89,8 @@ class ChildData {
imageBytes:
identical(imageBytes, _unsetImageBytes) ? this.imageBytes : imageBytes as Uint8List?,
cardColor: cardColor ?? this.cardColor,
repriseChildId: repriseChildId ?? this.repriseChildId,
existingPhotoUrl: existingPhotoUrl ?? this.existingPhotoUrl,
);
}
}
@@ -180,27 +190,17 @@ class UserRegistrationData extends ChangeNotifier {
/// Reprise après refus (#112) : réinitialise le flux parent avec les données dossier.
void resetForReprise({
required String firstName,
required String lastName,
required String phone,
required String email,
required String address,
required String postalCode,
required String city,
required ParentData parent1Data,
ParentData? parent2Data,
List<ChildData>? childrenData,
String motivation = '',
}) {
parent1 = ParentData(
firstName: firstName,
lastName: lastName,
phone: phone,
email: email,
address: address,
postalCode: postalCode,
city: city,
password: '',
);
parent2 = null;
children.clear();
motivationText = '';
parent1 = parent1Data;
parent2 = parent2Data;
children
..clear()
..addAll(childrenData ?? const []);
motivationText = motivation;
cguAccepted = false;
bankDetails = null;
attestationCafNumber = '';
@@ -208,11 +208,16 @@ class UserRegistrationData extends ChangeNotifier {
notifyListeners();
}
/// Reprise (#112) : coordonnées parent principal + CGU.
/// Reprise (#112) : coordonnées + enfants connus + CGU.
bool get isRepriseSubmitReady =>
parent1.firstName.isNotEmpty &&
parent1.lastName.isNotEmpty &&
parent1.email.isNotEmpty &&
children.isNotEmpty &&
children.every(
(c) =>
c.repriseChildId != null && c.repriseChildId!.trim().isNotEmpty,
) &&
cguAccepted;
// Méthode pour vérifier si toutes les données requises sont là (simplifié)