working leantime widget 121

This commit is contained in:
Alma 2025-04-12 23:01:09 +02:00
parent 840685ae26
commit 301d708263

View File

@ -81,10 +81,16 @@ export function Flow() {
};
const getValidDate = (task: Task): string | null => {
// Only use dateToFinish
// First check dateToFinish
if (task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00') {
return task.dateToFinish;
}
// Then check date
if (task.date && task.date !== '0000-00-00 00:00:00') {
return task.date;
}
return null;
};
@ -100,7 +106,7 @@ export function Flow() {
return;
}
// Filter out completed tasks (status 3) and sort by dateToFinish
// Filter out completed tasks (status 3) and sort by date
const sortedTasks = data
.filter((task: Task) => task.status !== 3)
.sort((a: Task, b: Task) => {
@ -114,7 +120,7 @@ export function Flow() {
return new Date(dateA).getTime() - new Date(dateB).getTime();
});
console.log('Sorted tasks by dateToFinish:', sortedTasks);
console.log('Sorted tasks:', sortedTasks);
setTasks(sortedTasks.slice(0, 6));
} catch (error) {
console.error('Error fetching tasks:', error);