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:
2026-06-21 17:42:00 +02:00
co-authored by Cursor
parent 1dddc67933
commit 8494341b56
11 changed files with 1075 additions and 458 deletions
+31 -15
View File
@@ -13,28 +13,44 @@ class ParentModel {
});
factory ParentModel.fromJson(Map<String, dynamic> json) {
final userJson = Map<String, dynamic>.from(json['user'] ?? json);
if (json['numero_dossier'] != null && userJson['numero_dossier'] == null) {
userJson['numero_dossier'] = json['numero_dossier'];
final root = Map<String, dynamic>.from(json);
final userJson = Map<String, dynamic>.from(root['user'] ?? root);
if (root['numero_dossier'] != null && userJson['numero_dossier'] == null) {
userJson['numero_dossier'] = root['numero_dossier'];
}
final user = AppUser.fromJson(userJson);
final children = <ParentChildSummary>[];
final links = json['parentChildren'] as List?;
if (links != null) {
for (final link in links) {
if (link is Map<String, dynamic> && link['child'] is Map<String, dynamic>) {
children.add(
ParentChildSummary.fromJson(link['child'] as Map<String, dynamic>),
);
}
}
}
final children = _parseChildren(root);
final links = root['parentChildren'] ?? root['parent_children'];
final linkCount = links is List ? links.length : 0;
return ParentModel(
user: user,
childrenCount: children.isNotEmpty ? children.length : (links?.length ?? 0),
childrenCount: children.isNotEmpty ? children.length : linkCount,
children: children,
);
}
static List<ParentChildSummary> _parseChildren(Map<String, dynamic> json) {
final children = <ParentChildSummary>[];
final seen = <String>{};
void add(ParentChildSummary? child) {
if (child == null || child.id.isEmpty || seen.contains(child.id)) return;
seen.add(child.id);
children.add(child);
}
final links = json['parentChildren'] ?? json['parent_children'];
if (links is List) {
for (final link in links) {
if (link is! Map) continue;
add(ParentChildSummary.fromParentChildLink(
Map<String, dynamic>.from(link),
));
}
}
return children;
}
}