mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 10:49:10 +02:00
Merge pull request #261 from R0m1k3/1.1
Fix task editing and creation errors in the API
This commit is contained in:
2 files changed
+10
-2
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user