Merge pull request #261 from R0m1k3/1.1

Fix task editing and creation errors in the API
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-19 12:39:50 +02:00
commit 81d9da11c3
2 files changed
+10 -2

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

+10 -2
View File
@@ -78,20 +78,28 @@ function TaskFormInline({ task, onClose }: any) {
};
const url = task ? `/api/tasks/${task.id}` : '/api/tasks';
const method = task ? 'PATCH' : 'POST';
const method = task ? 'PUT' : 'POST';
if (!task) {
(taskData as any).groupId = 1;
(taskData as any).createdBy = 'admin';
}
console.log('📤 Sending request:', { url, method, taskData });
const response = await fetch(url, {
method,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(taskData),
});
if (!response.ok) throw new Error(`Erreur ${response.status}`);
console.log('📥 Response:', { status: response.status, ok: response.ok });
if (!response.ok) {
const errorText = await response.text();
console.error('❌ API Error:', { status: response.status, error: errorText });
throw new Error(`Erreur ${response.status}: ${errorText}`);
}
alert(task ? "Tâche modifiée avec succès" : "Tâche créée avec succès");
window.location.reload();