fix(#112): dates et places AM en reprise (resetForReprise)

Corrige l’ombre des paramètres dateOfBirth, agreementDate et placesAvailable
dans resetForReprise ; renforce le parsing reprise-dossier et ajoute un test.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 19:12:14 +02:00
co-authored by Cursor
parent c26ed00374
commit df776d8200
7 changed files with 256 additions and 84 deletions
@@ -134,30 +134,7 @@ class _ProfessionalInfoFormScreenState extends State<ProfessionalInfoFormScreen>
@override
void initState() {
super.initState();
final data = widget.initialData;
if (data != null) {
_selectedDate = data.dateOfBirth;
_dateOfBirthController.text = data.dateOfBirth != null
? DateFormat('dd/MM/yyyy').format(data.dateOfBirth!)
: '';
_birthCityController.text = data.birthCity;
_birthCountryController.text = data.birthCountry;
final nirRaw = nirToRaw(data.nir);
_nirController.text = nirRaw.length == 15 ? formatNir(nirRaw) : data.nir;
_agrementController.text = data.agrementNumber;
_selectedAgreementDate = data.agreementDate;
_agreementDateController.text = data.agreementDate != null
? DateFormat('dd/MM/yyyy').format(data.agreementDate!)
: '';
_capacityController.text = data.capacity?.toString() ?? '';
_placesAvailableController.text = data.placesAvailable?.toString() ?? '';
_photoPathFramework = data.photoPath;
_photoFile = data.photoFile;
_photoBytes = data.photoBytes;
_photoFilename = data.photoFilename;
_photoConsent = data.photoConsent;
}
_applyInitialData(widget.initialData);
if (widget.mode == DisplayMode.editable) {
_birthCityFocus = FocusNode();
@@ -168,6 +145,51 @@ class _ProfessionalInfoFormScreenState extends State<ProfessionalInfoFormScreen>
}
}
@override
void didUpdateWidget(covariant ProfessionalInfoFormScreen oldWidget) {
super.didUpdateWidget(oldWidget);
final next = widget.initialData;
final prev = oldWidget.initialData;
if (next == null) return;
if (prev == null ||
prev.dateOfBirth != next.dateOfBirth ||
prev.agreementDate != next.agreementDate ||
prev.placesAvailable != next.placesAvailable ||
prev.capacity != next.capacity ||
prev.nir != next.nir ||
prev.birthCity != next.birthCity ||
prev.birthCountry != next.birthCountry ||
prev.agrementNumber != next.agrementNumber ||
prev.photoPath != next.photoPath ||
prev.photoConsent != next.photoConsent) {
_applyInitialData(next);
}
}
void _applyInitialData(ProfessionalInfoData? data) {
if (data == null) return;
_selectedDate = data.dateOfBirth;
_dateOfBirthController.text = data.dateOfBirth != null
? DateFormat('dd/MM/yyyy').format(data.dateOfBirth!)
: '';
_birthCityController.text = data.birthCity;
_birthCountryController.text = data.birthCountry;
final nirRaw = nirToRaw(data.nir);
_nirController.text = nirRaw.length == 15 ? formatNir(nirRaw) : data.nir;
_agrementController.text = data.agrementNumber;
_selectedAgreementDate = data.agreementDate;
_agreementDateController.text = data.agreementDate != null
? DateFormat('dd/MM/yyyy').format(data.agreementDate!)
: '';
_capacityController.text = data.capacity?.toString() ?? '';
_placesAvailableController.text = data.placesAvailable?.toString() ?? '';
_photoPathFramework = data.photoPath;
_photoFile = data.photoFile;
_photoBytes = data.photoBytes;
_photoFilename = data.photoFilename;
_photoConsent = data.photoConsent;
}
void _onBirthCityFocusChange() {
if (_birthCityFocus == null || _birthCityFocus!.hasFocus) return;
_applyPlaceNameFormat(_birthCityController);