feat(#140): fiches admin famille — IdentityBlock, parsing enfants et avatars web
Extrait IdentityBlock réutilisable, aligne les modales parent/enfant sur le style validation, corrige le parsing parentChildren et les URLs /uploads en Flutter web. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,9 +23,38 @@ class ParentChildSummary {
|
||||
factory ParentChildSummary.fromJson(Map<String, dynamic> json) {
|
||||
return ParentChildSummary(
|
||||
id: (json['id'] ?? '').toString(),
|
||||
firstName: json['first_name'] as String?,
|
||||
lastName: json['last_name'] as String?,
|
||||
status: (json['status'] ?? '').toString(),
|
||||
firstName: (json['first_name'] ?? json['prenom'])?.toString(),
|
||||
lastName: (json['last_name'] ?? json['nom'])?.toString(),
|
||||
status: (json['status'] ?? json['statut'] ?? '').toString(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Parse un lien `parentChildren` (objet enfant imbriqué ou id seul).
|
||||
static ParentChildSummary? fromParentChildLink(Map<String, dynamic> link) {
|
||||
final childRaw = link['child'] ?? link['enfant'];
|
||||
if (childRaw is Map) {
|
||||
return ParentChildSummary.fromJson(Map<String, dynamic>.from(childRaw));
|
||||
}
|
||||
|
||||
if (link.containsKey('first_name') ||
|
||||
link.containsKey('prenom') ||
|
||||
link.containsKey('id')) {
|
||||
final id = (link['id'] ?? '').toString();
|
||||
if (id.isNotEmpty &&
|
||||
(link.containsKey('first_name') || link.containsKey('prenom'))) {
|
||||
return ParentChildSummary.fromJson(link);
|
||||
}
|
||||
}
|
||||
|
||||
final enfantId =
|
||||
link['enfantId'] ?? link['id_enfant'] ?? link['enfant_id'];
|
||||
if (enfantId != null && enfantId.toString().isNotEmpty) {
|
||||
return ParentChildSummary(
|
||||
id: enfantId.toString(),
|
||||
status: '',
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user