feat(#132): création enfant admin — modale + sélection famille.

Onglet Enfants « Ajouter » ouvre la fiche en mode création ; bloc Famille/dossier ; client POST /enfants avec parent_user_id (contrat back à livrer).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-17 18:00:41 +02:00
co-authored by Cursor
parent 6fe2b89a61
commit c3acf1970d
4 changed files with 482 additions and 29 deletions
+26
View File
@@ -515,6 +515,32 @@ class UserService {
return enrichEnfantParentNames(enfant);
}
/// Création enfant côté staff (#132) — nécessite `POST /enfants` étendu (voir mini-spec).
/// [parentUserId] : parent pivot du foyer (`parent_user_id`).
static Future<EnfantAdminModel> createEnfant({
required String parentUserId,
required Map<String, dynamic> body,
}) async {
final payload = <String, dynamic>{
...body,
'parent_user_id': parentUserId,
};
final response = await http.post(
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.enfants}'),
headers: await _headers(),
body: jsonEncode(payload),
);
if (response.statusCode != 200 && response.statusCode != 201) {
throw Exception(
_extractErrorMessage(response.body, 'Erreur création enfant'),
);
}
final enfant = EnfantAdminModel.fromJson(
jsonDecode(response.body) as Map<String, dynamic>,
);
return enrichEnfantParentNames(enfant);
}
static Future<void> deleteEnfant(String enfantId) async {
final response = await http.delete(
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.enfants}/$enfantId'),