feat(front): alignement avec la spec backend soins enfant
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -91,6 +91,7 @@ class CardsService {
|
||||
required String dateDebut,
|
||||
required String dateFin,
|
||||
String? motif,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
final response = await http.post(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}'),
|
||||
@@ -101,6 +102,7 @@ class CardsService {
|
||||
'date_debut': dateDebut,
|
||||
'date_fin': dateFin,
|
||||
if (motif != null && motif.trim().isNotEmpty) 'motif': motif.trim(),
|
||||
if (payload != null) 'payload': payload,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -114,6 +116,49 @@ class CardsService {
|
||||
return CarteBulle.fromJson(Map<String, dynamic>.from(decoded as Map));
|
||||
}
|
||||
|
||||
/// Modifier une carte (corriger un soin, dates en attente...).
|
||||
static Future<CarteBulle> maj({
|
||||
required String cardId,
|
||||
String? dateDebut,
|
||||
String? dateFin,
|
||||
String? motif,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
final response = await http.patch(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}/$cardId'),
|
||||
headers: await _headers(),
|
||||
body: jsonEncode({
|
||||
if (dateDebut != null) 'date_debut': dateDebut,
|
||||
if (dateFin != null) 'date_fin': dateFin,
|
||||
if (motif != null && motif.trim().isNotEmpty) 'motif': motif.trim(),
|
||||
if (payload != null) 'payload': payload,
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception(
|
||||
_extractError(response.body, 'Erreur lors de la mise à jour'),
|
||||
);
|
||||
}
|
||||
|
||||
final decoded = jsonDecode(response.body);
|
||||
return CarteBulle.fromJson(Map<String, dynamic>.from(decoded as Map));
|
||||
}
|
||||
|
||||
/// Supprimer une bulle (AM 24h ou avant traitement).
|
||||
static Future<void> supprimer(String cardId) async {
|
||||
final response = await http.delete(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}/$cardId'),
|
||||
headers: await _headers(),
|
||||
);
|
||||
|
||||
if (response.statusCode != 204 && response.statusCode != 200) {
|
||||
throw Exception(
|
||||
_extractError(response.body, 'Erreur lors de la suppression'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Répondre : accept | refuse | ack.
|
||||
static Future<CarteBulle> repondre({
|
||||
required String cardId,
|
||||
|
||||
Reference in New Issue
Block a user