working leantime widget 98

This commit is contained in:
Alma 2025-04-12 21:17:18 +02:00
parent 0bf7c435db
commit 6c138e4a79

View File

@ -97,12 +97,7 @@ export function Flow() {
// Debug log to see all tasks and their dates
data.tasks.forEach((task: Task) => {
console.log(`Task ${task.id} - ${task.headline} dates:`, {
dateToFinish: task.dateToFinish,
editFrom: task.editFrom,
editTo: task.editTo,
date: task.date
});
console.log(`Task ${task.id} - ${task.headline}:`, task);
});
const getValidDate = (task: Task): Date | undefined => {
@ -144,17 +139,24 @@ export function Flow() {
if (a.validDate && b.validDate) {
return a.validDate.getTime() - b.validDate.getTime();
}
// If only one task has a date, put it first
if (a.validDate) return -1;
if (b.validDate) return 1;
// If neither has a date, sort by ID
return a.id - b.id;
// If neither has a date, sort by ID (most recent first)
if (!a.validDate && !b.validDate) {
return b.id - a.id; // Reverse ID sort for undated tasks
}
// Put tasks without dates at the end
if (!a.validDate) return 1;
if (!b.validDate) return -1;
return 0;
});
console.log('Final sorted tasks:', sortedTasks.map((t: TaskWithDate) => ({
id: t.id,
headline: t.headline,
date: t.validDate?.toISOString()
date: t.validDate?.toISOString(),
status: t.status,
dateToFinish: t.dateToFinish,
editFrom: t.editFrom,
editTo: t.editTo
})));
setTasks(sortedTasks);