feat(front): inscription parent — genre obligatoire H/F/Autre (#101)
- ChildData.genre + copyWith ; liste déroulante sur la carte enfant - Validation et payload API alignés sur GenreType - Étape 3 : mises à jour via copyWith (préservation du genre) Made-with: Cursor
This commit is contained in:
@@ -8,6 +8,8 @@ class ParentRegistrationPayload {
|
||||
ParentRegistrationPayload._();
|
||||
|
||||
static final RegExp _phoneFr = RegExp(r'^(\+33|0)[1-9](\d{2}){4}$');
|
||||
/// Aligné sur `GenreType` (backend) : JSON exact `H`, `F`, `Autre`.
|
||||
static const Set<String> apiGenres = {'H', 'F', 'Autre'};
|
||||
|
||||
/// Retourne un message d'erreur utilisateur, ou `null` si le formulaire est cohérent.
|
||||
static String? validateForApi(UserRegistrationData d) {
|
||||
@@ -57,6 +59,9 @@ class ParentRegistrationPayload {
|
||||
for (var i = 0; i < d.children.length; i++) {
|
||||
final c = d.children[i];
|
||||
final label = 'Enfant ${i + 1}';
|
||||
if (!apiGenres.contains(c.genre)) {
|
||||
return '$label : sélectionnez le genre (garçon, fille ou autre).';
|
||||
}
|
||||
if (c.isUnbornChild) {
|
||||
final due = _ddMmYyyyToIso(c.dob);
|
||||
if (due == null) {
|
||||
@@ -130,7 +135,7 @@ class ParentRegistrationPayload {
|
||||
|
||||
static Map<String, dynamic> _childToJson(ChildData c, int index, String parentNom) {
|
||||
final map = <String, dynamic>{
|
||||
'genre': 'F',
|
||||
'genre': c.genre,
|
||||
'grossesse_multiple': c.multipleBirth,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user