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:
@@ -141,14 +141,14 @@ class AmRegistrationData extends ChangeNotifier {
|
||||
photoBytes = null;
|
||||
photoFilename = null;
|
||||
photoConsent = consentementPhoto;
|
||||
dateOfBirth = dateOfBirth;
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
this.birthCity = birthCity;
|
||||
this.birthCountry = birthCountry;
|
||||
this.nir = nir;
|
||||
this.agrementNumber = agrementNumber;
|
||||
agreementDate = agreementDate;
|
||||
this.agreementDate = agreementDate;
|
||||
this.capacity = capacity;
|
||||
placesAvailable = placesAvailable;
|
||||
this.placesAvailable = placesAvailable;
|
||||
this.presentationText = presentationText;
|
||||
cguAccepted = false;
|
||||
notifyListeners();
|
||||
|
||||
@@ -64,7 +64,22 @@ class RepriseDossier {
|
||||
bool get isParent => role == 'parent';
|
||||
bool get isAm => role == 'assistante_maternelle';
|
||||
|
||||
static Map<String, dynamic>? _nestedMap(dynamic value) {
|
||||
if (value is Map) return Map<String, dynamic>.from(value);
|
||||
return null;
|
||||
}
|
||||
|
||||
static dynamic _firstNonNull(List<dynamic> values) {
|
||||
for (final v in values) {
|
||||
if (v != null) return v;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
factory RepriseDossier.fromJson(Map<String, dynamic> json) {
|
||||
final nestedUser = _nestedMap(json['user']);
|
||||
final nestedDossier = _nestedMap(json['dossier']);
|
||||
|
||||
final parentsRaw = json['parents'];
|
||||
final parentsList = parentsRaw is List
|
||||
? parentsRaw
|
||||
@@ -100,19 +115,64 @@ class RepriseDossier {
|
||||
texteMotivation: (json['texte_motivation'] ?? json['presentation_dossier'])
|
||||
?.toString(),
|
||||
consentementPhoto: RepriseMapper.optionalBool(json['consentement_photo']) ||
|
||||
RepriseMapper.optionalBool(json['consent_photo']),
|
||||
dateNaissance: RepriseMapper.optionalDateString(json['date_naissance']),
|
||||
lieuNaissanceVille: json['lieu_naissance_ville']?.toString(),
|
||||
lieuNaissancePays: json['lieu_naissance_pays']?.toString(),
|
||||
numeroAgrement: (json['numero_agrement'] ?? json['numero_agrement_am'])
|
||||
?.toString(),
|
||||
nir: json['nir']?.toString(),
|
||||
dateAgrement: RepriseMapper.optionalDateString(json['date_agrement']),
|
||||
RepriseMapper.optionalBool(json['consent_photo']) ||
|
||||
RepriseMapper.optionalBool(nestedUser?['consentement_photo']),
|
||||
dateNaissance: RepriseMapper.optionalDateString(
|
||||
_firstNonNull([
|
||||
json['date_naissance'],
|
||||
json['dateNaissance'],
|
||||
nestedUser?['date_naissance'],
|
||||
nestedUser?['dateNaissance'],
|
||||
]),
|
||||
),
|
||||
lieuNaissanceVille: _firstNonNull([
|
||||
json['lieu_naissance_ville'],
|
||||
json['lieuNaissanceVille'],
|
||||
nestedUser?['lieu_naissance_ville'],
|
||||
nestedUser?['lieuNaissanceVille'],
|
||||
])?.toString(),
|
||||
lieuNaissancePays: _firstNonNull([
|
||||
json['lieu_naissance_pays'],
|
||||
json['lieuNaissancePays'],
|
||||
nestedUser?['lieu_naissance_pays'],
|
||||
nestedUser?['lieuNaissancePays'],
|
||||
])?.toString(),
|
||||
numeroAgrement: _firstNonNull([
|
||||
json['numero_agrement'],
|
||||
json['numero_agrement_am'],
|
||||
json['numeroAgrement'],
|
||||
nestedDossier?['numero_agrement'],
|
||||
nestedDossier?['numeroAgrement'],
|
||||
])?.toString(),
|
||||
nir: _firstNonNull([
|
||||
json['nir'],
|
||||
nestedDossier?['nir'],
|
||||
])?.toString(),
|
||||
dateAgrement: RepriseMapper.optionalDateString(
|
||||
_firstNonNull([
|
||||
json['date_agrement'],
|
||||
json['dateAgrement'],
|
||||
nestedDossier?['date_agrement'],
|
||||
nestedDossier?['dateAgrement'],
|
||||
]),
|
||||
),
|
||||
nbMaxEnfants: RepriseMapper.optionalInt(
|
||||
json['nb_max_enfants'] ?? json['capacite_accueil'],
|
||||
_firstNonNull([
|
||||
json['nb_max_enfants'],
|
||||
json['capacite_accueil'],
|
||||
json['nbMaxEnfants'],
|
||||
nestedDossier?['nb_max_enfants'],
|
||||
nestedDossier?['capacite_accueil'],
|
||||
]),
|
||||
),
|
||||
placeDisponible: RepriseMapper.optionalInt(
|
||||
json['place_disponible'] ?? json['places_disponibles'],
|
||||
_firstNonNull([
|
||||
json['place_disponible'],
|
||||
json['places_disponibles'],
|
||||
json['placesDisponibles'],
|
||||
nestedDossier?['place_disponible'],
|
||||
nestedDossier?['places_disponibles'],
|
||||
]),
|
||||
),
|
||||
biographie: (json['biographie'] ?? json['presentation'])?.toString(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user