working leantime widget 136
This commit is contained in:
parent
50ecd1866c
commit
7e1a734085
@ -112,28 +112,36 @@ export function Flow() {
|
||||
return isValid;
|
||||
})
|
||||
.sort((a: Task, b: Task) => {
|
||||
// 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)
|
||||
// First sort by dateToFinish (oldest first)
|
||||
const dateA = getValidDate(a);
|
||||
const dateB = getValidDate(b);
|
||||
|
||||
// If both dates are valid, compare them
|
||||
if (dateA && dateB) {
|
||||
return new Date(dateA).getTime() - new Date(dateB).getTime();
|
||||
const timeA = new Date(dateA).getTime();
|
||||
const timeB = new Date(dateB).getTime();
|
||||
if (timeA !== timeB) {
|
||||
return timeA - timeB;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// If dates are equal or neither has a date, sort by status (4 before others)
|
||||
if (a.status === 4 && b.status !== 4) return -1;
|
||||
if (b.status === 4 && a.status !== 4) return 1;
|
||||
|
||||
// If status is also equal, maintain original order
|
||||
return 0;
|
||||
});
|
||||
|
||||
console.log('Sorted tasks:', sortedTasks);
|
||||
console.log('Sorted tasks:', sortedTasks.map(t => ({
|
||||
id: t.id,
|
||||
date: t.dateToFinish,
|
||||
status: t.status
|
||||
})));
|
||||
setTasks(sortedTasks.slice(0, 7));
|
||||
} catch (error) {
|
||||
console.error('Error fetching tasks:', error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user