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:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user