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 => {
|
||||
// Only use dateToFinish
|
||||
if (task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00') {
|
||||
return task.dateToFinish;
|
||||
}
|
||||
@ -100,21 +99,23 @@ export function Flow() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter out completed tasks (status 3) and sort by dateToFinish
|
||||
const sortedTasks = data
|
||||
.filter((task: Task) => task.status !== 3)
|
||||
.sort((a: Task, b: Task) => {
|
||||
const dateA = getValidDate(a);
|
||||
const dateB = getValidDate(b);
|
||||
|
||||
if (!dateA && !dateB) return 0;
|
||||
if (!dateA) return 1;
|
||||
if (!dateB) return -1;
|
||||
|
||||
return new Date(dateA).getTime() - new Date(dateB).getTime();
|
||||
// Process tasks with valid dates
|
||||
const processedTasks = data.map((task: Task) => {
|
||||
const dateStr = getValidDate(task);
|
||||
return {
|
||||
...task,
|
||||
validDate: dateStr ? new Date(dateStr) : undefined
|
||||
};
|
||||
});
|
||||
|
||||
// Filter and sort tasks - include status 3 (In Progress)
|
||||
const sortedTasks = processedTasks
|
||||
.filter((task: TaskWithDate) => task.validDate) // Only keep tasks with valid dates
|
||||
.sort((a: TaskWithDate, b: TaskWithDate) => {
|
||||
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);
|
||||
setTasks(sortedTasks.slice(0, 6));
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user