widget leantime refactor
This commit is contained in:
parent
aa0e5f42bd
commit
c9cc0b666b
@ -146,9 +146,12 @@ export function Duties() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Backend already filters out status=5 (Done) and filters by editorId for Leantime
|
// Backend already filters out status=5 (Done) and filters by editorId for Leantime
|
||||||
// Filter to keep only tasks with due date before today (past due)
|
// Backend also filters Twenty CRM tasks to include overdue and due today
|
||||||
const today = new Date();
|
// Filter to keep only tasks with due date <= today (overdue or due today)
|
||||||
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison
|
const now = new Date();
|
||||||
|
const todayYear = now.getFullYear();
|
||||||
|
const todayMonth = now.getMonth();
|
||||||
|
const todayDay = now.getDate();
|
||||||
|
|
||||||
const filteredTasks = allTasks.filter((task: Task) => {
|
const filteredTasks = allTasks.filter((task: Task) => {
|
||||||
const dueDate = getValidDate(task);
|
const dueDate = getValidDate(task);
|
||||||
@ -156,11 +159,18 @@ export function Duties() {
|
|||||||
return false; // Exclude tasks without a due date
|
return false; // Exclude tasks without a due date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use local date comparison to avoid timezone issues
|
||||||
const taskDueDate = new Date(dueDate);
|
const taskDueDate = new Date(dueDate);
|
||||||
taskDueDate.setHours(0, 0, 0, 0); // Set to start of day for accurate comparison
|
const taskYear = taskDueDate.getFullYear();
|
||||||
|
const taskMonth = taskDueDate.getMonth();
|
||||||
|
const taskDay = taskDueDate.getDate();
|
||||||
|
|
||||||
// Keep only tasks with due date before today (past due)
|
// Keep tasks with due date <= today (overdue or due today)
|
||||||
return taskDueDate < today;
|
const isOverdueOrDueToday = taskYear < todayYear ||
|
||||||
|
(taskYear === todayYear && taskMonth < todayMonth) ||
|
||||||
|
(taskYear === todayYear && taskMonth === todayMonth && taskDay <= todayDay);
|
||||||
|
|
||||||
|
return isOverdueOrDueToday;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sort by dateToFinish (oldest first)
|
// Sort by dateToFinish (oldest first)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user