Fix : Mise a jour et création d'un événement

This commit is contained in:
ElPoyo
2026-01-13 17:26:09 +01:00
parent 2bcd1ca4c3
commit 0f7a886cf7
5 changed files with 37 additions and 10 deletions

View File

@@ -118,10 +118,17 @@ class EventFormService {
static Future<void> updateEvent(EventModel event) async {
try {
await _apiService.call('updateEvent', {
'eventId': event.id,
'data': event.toMap(),
});
if (event.id.isEmpty) {
throw Exception("Cannot update event: Event ID is empty");
}
developer.log('Updating event with ID: ${event.id}', name: 'EventFormService');
final eventData = event.toMap();
eventData['eventId'] = event.id;
await _apiService.call('updateEvent', eventData);
developer.log('Event updated successfully', name: 'EventFormService');
} catch (e) {
developer.log('Error updating event', name: 'EventFormService', error: e);
rethrow;
@@ -172,12 +179,19 @@ class EventFormService {
}
static Future<void> updateEventDocuments(String eventId, List<Map<String, String>> documents) async {
// Utiliser l'API pour mettre à jour les documents
try {
if (eventId.isEmpty) {
throw Exception("Event ID cannot be empty");
}
developer.log('Updating event documents for ID: $eventId (${documents.length} documents)', name: 'EventFormService');
await _apiService.call('updateEvent', {
'eventId': eventId,
'documents': documents,
});
developer.log('Event documents updated successfully', name: 'EventFormService');
} catch (e) {
developer.log('Error updating event documents', name: 'EventFormService', error: e);
throw Exception("Could not update event documents.");