loading duration

This commit is contained in:
Bastien COIGNOUX
2025-07-14 15:59:04 +02:00
parent f999b17150
commit ce5fd5621e
3 changed files with 32 additions and 9 deletions

Binary file not shown.

View File

@ -10,15 +10,31 @@
];
onMount(async () => {
const res = await fetch('/api/tasks');
if (res.ok) {
const { tasks: loadedTasks, links: loadedLinks } = await res.json();
tasks = loadedTasks;
links = loadedLinks;
} else {
console.error('Erreur de chargement des données depuis la base.');
}
});
const res = await fetch('/api/tasks');
if (res.ok) {
const { tasks: loadedTasks, links: loadedLinks } = await res.json();
tasks = loadedTasks.map(task => {
// Assure que start est une date ISO
const start = new Date(task.start);
const duration = task.duration || task.estimation || 1;
const end = new Date(start);
end.setDate(start.getDate() + duration);
return {
...task,
start: start.toISOString().slice(0, 10), // "YYYY-MM-DD"
end: end.toISOString().slice(0, 10)
};
});
links = loadedLinks;
} else {
console.error('Erreur de chargement des données depuis la base.');
}
});
</script>
<Willow>