working leantime widget 96

This commit is contained in:
Alma 2025-04-12 21:10:08 +02:00
parent 5b47e13c38
commit 0d01d513ec

View File

@ -139,9 +139,16 @@ export function Flow() {
...task,
validDate: getValidDate(task)
}))
.filter((task: TaskWithDate) => task.validDate !== undefined)
.sort((a: TaskWithDate, b: TaskWithDate) => {
return (a.validDate as Date).getTime() - (b.validDate as Date).getTime();
// If both tasks have dates, sort by date
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;
})
.slice(0, 6);