Allow user to assign to a task

This commit is contained in:
T'JAMPENS QUENTIN p2406187
2026-01-12 14:11:51 +01:00
parent bb369c629b
commit 00142f1e3e
2 changed files with 40 additions and 3 deletions
+32
View File
@@ -0,0 +1,32 @@
import getXSRFToken from "../getXSRF.js";
export default async function assign(taskId) {
const csrfToken = await getXSRFToken();
try {
const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/events/task/assign`, {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-XSRF-TOKEN': csrfToken,
},
body: JSON.stringify({
task_id: taskId
}),
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
const data = await res.json();
return data;
} catch (err) {
console.error('Erreur :', err);
return null;
}
}