widget leantime refactor

This commit is contained in:
alma 2026-01-15 23:03:53 +01:00
parent 6cce6d4269
commit aa0e5f42bd

View File

@ -248,20 +248,21 @@ async function fetchTwentyTasks(): Promise<TwentyTask[]> {
const taskMonth = taskDueDate.getMonth(); const taskMonth = taskDueDate.getMonth();
const taskDay = taskDueDate.getDate(); const taskDay = taskDueDate.getDate();
// Compare dates: task is overdue if its date is before today's date // Compare dates: task is overdue or due today if its date is before or equal to today's date
const isOverdue = taskYear < todayYear || // (includes tasks due today)
const isOverdueOrDueToday = taskYear < todayYear ||
(taskYear === todayYear && taskMonth < todayMonth) || (taskYear === todayYear && taskMonth < todayMonth) ||
(taskYear === todayYear && taskMonth === todayMonth && taskDay < todayDay); (taskYear === todayYear && taskMonth === todayMonth && taskDay <= todayDay);
logger.error('[TWENTY_CRM_TASKS] Task date check', { logger.error('[TWENTY_CRM_TASKS] Task date check', {
id: task.id, id: task.id,
dueAt: task.dueAt, dueAt: task.dueAt,
taskDate: `${taskYear}-${String(taskMonth + 1).padStart(2, '0')}-${String(taskDay).padStart(2, '0')}`, taskDate: `${taskYear}-${String(taskMonth + 1).padStart(2, '0')}-${String(taskDay).padStart(2, '0')}`,
todayDate: `${todayYear}-${String(todayMonth + 1).padStart(2, '0')}-${String(todayDay).padStart(2, '0')}`, todayDate: `${todayYear}-${String(todayMonth + 1).padStart(2, '0')}-${String(todayDay).padStart(2, '0')}`,
isOverdue, isOverdueOrDueToday,
}); });
return isOverdue; // Only overdue tasks return isOverdueOrDueToday; // Include overdue tasks and tasks due today
}) })
.sort((a: TwentyTask, b: TwentyTask) => { .sort((a: TwentyTask, b: TwentyTask) => {
// Sort by dueAt (oldest first) // Sort by dueAt (oldest first)