loading duration
This commit is contained in:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user