feat(#129): wizard admin création dossier famille (create/review).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -645,6 +645,54 @@ class UserService {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/// Création dossier famille actif côté staff (#129).
|
||||
/// `POST /parents/dossier` — body aligné sur register parent complet.
|
||||
/// Succès 201 : dossier actif + `numero_dossier` (mail MDP côté serveur, par parent créé).
|
||||
/// Ne pas utiliser `POST /auth/register/parent` (public / en_attente).
|
||||
static Future<Map<String, dynamic>> createParentDossier(
|
||||
Map<String, dynamic> body,
|
||||
) async {
|
||||
final http.Response response;
|
||||
try {
|
||||
response = await http.post(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.parentsDossier}'),
|
||||
headers: await _headers(),
|
||||
body: jsonEncode(body),
|
||||
);
|
||||
} on http.ClientException {
|
||||
throw Exception(
|
||||
'Connexion au serveur impossible. Vérifiez votre réseau puis réessayez.',
|
||||
);
|
||||
}
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
if (response.body.trim().isEmpty) return <String, dynamic>{};
|
||||
try {
|
||||
final decoded = jsonDecode(response.body);
|
||||
if (decoded is Map) {
|
||||
return Map<String, dynamic>.from(decoded);
|
||||
}
|
||||
} catch (_) {}
|
||||
return <String, dynamic>{};
|
||||
}
|
||||
|
||||
final message = _extractErrorMessage(
|
||||
response.body,
|
||||
'Erreur création dossier famille',
|
||||
);
|
||||
if (response.statusCode == 409) {
|
||||
throw Exception(
|
||||
message.isNotEmpty ? message : 'Conflit : e-mail déjà utilisé.',
|
||||
);
|
||||
}
|
||||
if (response.statusCode == 400) {
|
||||
throw Exception(
|
||||
message.isNotEmpty ? message : 'Données invalides (400).',
|
||||
);
|
||||
}
|
||||
throw Exception(message);
|
||||
}
|
||||
|
||||
/// Création dossier AM actif côté staff (#156).
|
||||
/// `POST /assistantes-maternelles/dossier` — body aligné sur register AM.
|
||||
/// Succès 201 : dossier actif + `numero_dossier` (mail MDP côté serveur).
|
||||
|
||||
Reference in New Issue
Block a user