working leantime widget 98
This commit is contained in:
parent
0bf7c435db
commit
6c138e4a79
@ -97,12 +97,7 @@ export function Flow() {
|
|||||||
|
|
||||||
// Debug log to see all tasks and their dates
|
// Debug log to see all tasks and their dates
|
||||||
data.tasks.forEach((task: Task) => {
|
data.tasks.forEach((task: Task) => {
|
||||||
console.log(`Task ${task.id} - ${task.headline} dates:`, {
|
console.log(`Task ${task.id} - ${task.headline}:`, task);
|
||||||
dateToFinish: task.dateToFinish,
|
|
||||||
editFrom: task.editFrom,
|
|
||||||
editTo: task.editTo,
|
|
||||||
date: task.date
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getValidDate = (task: Task): Date | undefined => {
|
const getValidDate = (task: Task): Date | undefined => {
|
||||||
@ -144,17 +139,24 @@ export function Flow() {
|
|||||||
if (a.validDate && b.validDate) {
|
if (a.validDate && b.validDate) {
|
||||||
return a.validDate.getTime() - b.validDate.getTime();
|
return a.validDate.getTime() - b.validDate.getTime();
|
||||||
}
|
}
|
||||||
// If only one task has a date, put it first
|
// If neither has a date, sort by ID (most recent first)
|
||||||
if (a.validDate) return -1;
|
if (!a.validDate && !b.validDate) {
|
||||||
if (b.validDate) return 1;
|
return b.id - a.id; // Reverse ID sort for undated tasks
|
||||||
// If neither has a date, sort by ID
|
}
|
||||||
return a.id - b.id;
|
// 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) => ({
|
console.log('Final sorted tasks:', sortedTasks.map((t: TaskWithDate) => ({
|
||||||
id: t.id,
|
id: t.id,
|
||||||
headline: t.headline,
|
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);
|
setTasks(sortedTasks);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user