widget leantime refactor

This commit is contained in:
alma 2026-01-15 23:05:58 +01:00
parent aa0e5f42bd
commit c9cc0b666b

View File

@ -146,9 +146,12 @@ export function Duties() {
}
// 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)
const today = new Date();
today.setHours(0, 0, 0, 0); // Set to start of today for accurate comparison
// Backend also filters Twenty CRM tasks to include overdue and due today
// Filter to keep only tasks with due date <= today (overdue or due today)
const now = new Date();
const todayYear = now.getFullYear();
const todayMonth = now.getMonth();
const todayDay = now.getDate();
const filteredTasks = allTasks.filter((task: Task) => {
const dueDate = getValidDate(task);
@ -156,11 +159,18 @@ export function Duties() {
return false; // Exclude tasks without a due date
}
// Use local date comparison to avoid timezone issues
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)
return taskDueDate < today;
// Keep tasks with due date <= today (overdue or due today)
const isOverdueOrDueToday = taskYear < todayYear ||
(taskYear === todayYear && taskMonth < todayMonth) ||
(taskYear === todayYear && taskMonth === todayMonth && taskDay <= todayDay);
return isOverdueOrDueToday;
});
// Sort by dateToFinish (oldest first)