working leantime widget 135

This commit is contained in:
Alma 2025-04-12 23:48:00 +02:00
parent ea2eecc43c
commit 50ecd1866c

View File

@ -112,20 +112,25 @@ export function Flow() {
return isValid;
})
.sort((a: Task, b: Task) => {
// First sort by status (4 before 3)
if (a.status !== b.status) {
return a.status === 4 ? -1 : 1;
}
// First sort by status (4 before others)
if (a.status === 4 && b.status !== 4) return -1;
if (b.status === 4 && a.status !== 4) return 1;
// Then sort by dateToFinish (oldest first)
const dateA = getValidDate(a);
const dateB = getValidDate(b);
if (!dateA && !dateB) return 0;
if (!dateA) return 1;
if (!dateB) return -1;
// If both dates are valid, compare them
if (dateA && dateB) {
return new Date(dateA).getTime() - new Date(dateB).getTime();
}
return new Date(dateA).getTime() - new Date(dateB).getTime();
// If only one date is valid, put the task with a date first
if (dateA) return -1;
if (dateB) return 1;
// If neither has a date, maintain their original order
return 0;
});
console.log('Sorted tasks:', sortedTasks);