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:
2026-03-28 18:08:32 +01:00
parent de60a001cc
commit cd2bf63b8a
5 changed files with 145 additions and 66 deletions
@@ -19,6 +19,8 @@ class ChildCardWidget extends StatefulWidget {
final VoidCallback onDateSelect;
final ValueChanged<String> onFirstNameChanged;
final ValueChanged<String> onLastNameChanged;
/// `H`, `F` ou `Autre` (GenreType API).
final ValueChanged<String> onGenreChanged;
final ValueChanged<bool> onTogglePhotoConsent;
final ValueChanged<bool> onToggleMultipleBirth;
final ValueChanged<bool> onToggleIsUnborn;
@@ -35,6 +37,7 @@ class ChildCardWidget extends StatefulWidget {
required this.onDateSelect,
required this.onFirstNameChanged,
required this.onLastNameChanged,
required this.onGenreChanged,
required this.onTogglePhotoConsent,
required this.onToggleMultipleBirth,
required this.onToggleIsUnborn,
@@ -190,6 +193,8 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
hint: 'Nom de l\'enfant',
),
SizedBox(height: 8.0 * scaleFactor),
_buildGenreField(context, config, scaleFactor),
SizedBox(height: 8.0 * scaleFactor),
_buildField(
config: config,
scaleFactor: scaleFactor,
@@ -352,6 +357,8 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
const SizedBox(height: 12),
_buildReadonlyField('Nom :', _lastNameController.text),
const SizedBox(height: 12),
_buildReadonlyField('Genre :', _genreDisplayLabel(widget.childData.genre)),
const SizedBox(height: 12),
_buildReadonlyField(
widget.childData.isUnbornChild ? 'Date prévisionnelle :' : 'Date de naissance :',
_dobController.text
@@ -467,6 +474,8 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
const SizedBox(height: 8),
_buildReadonlyField('Nom :', _lastNameController.text),
const SizedBox(height: 8),
_buildReadonlyField('Genre :', _genreDisplayLabel(widget.childData.genre)),
const SizedBox(height: 8),
_buildReadonlyField(
widget.childData.isUnbornChild ? 'Date prévisionnelle :' : 'Date de naissance :',
_dobController.text
@@ -556,6 +565,72 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
);
}
static String _genreDisplayLabel(String g) {
switch (g) {
case 'H':
return 'Garçon';
case 'F':
return 'Fille';
case 'Autre':
return 'Autre / ne souhaite pas préciser';
default:
return '';
}
}
Widget _buildGenreField(BuildContext context, DisplayConfig config, double scaleFactor) {
if (config.isReadonly) {
return FormFieldWrapper(
config: config,
label: 'Genre',
value: _genreDisplayLabel(widget.childData.genre),
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Genre *',
style: GoogleFonts.merienda(
fontSize: config.isMobile ? 12.0 : 18.0 * scaleFactor,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 4.0 * scaleFactor),
Container(
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 14.0 * scaleFactor, vertical: 4.0),
decoration: BoxDecoration(
image: const DecorationImage(
image: AssetImage('assets/images/bg_beige.png'),
fit: BoxFit.fill,
),
borderRadius: BorderRadius.circular(8 * scaleFactor),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
isExpanded: true,
value: widget.childData.genre.isEmpty ? null : widget.childData.genre,
hint: Text('Choisir', style: GoogleFonts.merienda(fontSize: config.isMobile ? 13.0 : 16.0)),
style: GoogleFonts.merienda(fontSize: config.isMobile ? 13.0 : 16.0, color: Colors.black87),
items: [
DropdownMenuItem(value: 'H', child: Text('Garçon', style: GoogleFonts.merienda())),
DropdownMenuItem(value: 'F', child: Text('Fille', style: GoogleFonts.merienda())),
DropdownMenuItem(
value: 'Autre',
child: Text('Autre / ne souhaite pas préciser', style: GoogleFonts.merienda()),
),
],
onChanged: (v) {
if (v != null) widget.onGenreChanged(v);
},
),
),
),
],
);
}
Widget _buildField({
required DisplayConfig config,
required double scaleFactor,