feat(#156): création dossier AM staff — API + wizard dashboard.
Squash depuis develop : POST /assistantes-maternelles/dossier (actif + mail MDP), AmDossierWizard create/review, validations inscription. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -645,6 +645,56 @@ class UserService {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/// 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).
|
||||
/// Ne pas utiliser `POST /auth/register/am` (public / en_attente).
|
||||
static Future<Map<String, dynamic>> createAmDossier(
|
||||
Map<String, dynamic> body,
|
||||
) async {
|
||||
final http.Response response;
|
||||
try {
|
||||
response = await http.post(
|
||||
Uri.parse(
|
||||
'${ApiConfig.baseUrl}${ApiConfig.assistantesMaternellesDossier}',
|
||||
),
|
||||
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 AM',
|
||||
);
|
||||
if (response.statusCode == 409) {
|
||||
throw Exception(message.isNotEmpty
|
||||
? message
|
||||
: 'Conflit : e-mail, NIR ou agrément déjà utilisé.');
|
||||
}
|
||||
if (response.statusCode == 400) {
|
||||
throw Exception(
|
||||
message.isNotEmpty ? message : 'Données invalides (400).',
|
||||
);
|
||||
}
|
||||
throw Exception(message);
|
||||
}
|
||||
|
||||
// Récupérer la liste des assistantes maternelles
|
||||
static Future<List<AssistanteMaternelleModel>>
|
||||
getAssistantesMaternelles() async {
|
||||
|
||||
Reference in New Issue
Block a user