working leantime widget 119
This commit is contained in:
parent
234b720f49
commit
94aac5fc4a
@ -81,7 +81,6 @@ export function Flow() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getValidDate = (task: Task): string | null => {
|
const getValidDate = (task: Task): string | null => {
|
||||||
// Only use dateToFinish
|
|
||||||
if (task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00') {
|
if (task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00') {
|
||||||
return task.dateToFinish;
|
return task.dateToFinish;
|
||||||
}
|
}
|
||||||
@ -100,21 +99,23 @@ export function Flow() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out completed tasks (status 3) and sort by dateToFinish
|
// Process tasks with valid dates
|
||||||
const sortedTasks = data
|
const processedTasks = data.map((task: Task) => {
|
||||||
.filter((task: Task) => task.status !== 3)
|
const dateStr = getValidDate(task);
|
||||||
.sort((a: Task, b: Task) => {
|
return {
|
||||||
const dateA = getValidDate(a);
|
...task,
|
||||||
const dateB = getValidDate(b);
|
validDate: dateStr ? new Date(dateStr) : undefined
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
if (!dateA && !dateB) return 0;
|
// Filter and sort tasks - include status 3 (In Progress)
|
||||||
if (!dateA) return 1;
|
const sortedTasks = processedTasks
|
||||||
if (!dateB) return -1;
|
.filter((task: TaskWithDate) => task.validDate) // Only keep tasks with valid dates
|
||||||
|
.sort((a: TaskWithDate, b: TaskWithDate) => {
|
||||||
return new Date(dateA).getTime() - new Date(dateB).getTime();
|
if (!a.validDate || !b.validDate) return 0;
|
||||||
|
return a.validDate.getTime() - b.validDate.getTime();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only log the count of tasks for security
|
|
||||||
console.log('Number of tasks found:', sortedTasks.length);
|
console.log('Number of tasks found:', sortedTasks.length);
|
||||||
setTasks(sortedTasks.slice(0, 6));
|
setTasks(sortedTasks.slice(0, 6));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user