From 9ff8c3ca7a19cd849022c075d3b7b7351235c57b Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 15 Jan 2026 22:55:30 +0100 Subject: [PATCH] widget leantime refactor --- app/api/twenty-crm/tasks/route.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/twenty-crm/tasks/route.ts b/app/api/twenty-crm/tasks/route.ts index c98117d..e2711f4 100644 --- a/app/api/twenty-crm/tasks/route.ts +++ b/app/api/twenty-crm/tasks/route.ts @@ -43,9 +43,9 @@ async function fetchTwentyTasks(): Promise { : `${process.env.TWENTY_CRM_API_URL}/graphql`; // Calculate today's date at midnight for filtering overdue tasks - const today = new Date(); - today.setHours(0, 0, 0, 0); - const todayISO = today.toISOString(); + const todayForISO = new Date(); + todayForISO.setHours(0, 0, 0, 0); + const todayISO = todayForISO.toISOString(); // GraphQL query to fetch tasks from Twenty CRM // bodyV2 is RichTextV2 type - trying common subfields @@ -221,8 +221,8 @@ async function fetchTwentyTasks(): Promise { }); // Filter client-side for overdue tasks (dueAt < today) and not completed (status !== 'Done') - const today = new Date(); - today.setHours(0, 0, 0, 0); + const todayForFilter = new Date(); + todayForFilter.setHours(0, 0, 0, 0); const tasks: TwentyTask[] = allTasks .filter((task: TwentyTask) => { @@ -240,12 +240,12 @@ async function fetchTwentyTasks(): Promise { const taskDueDate = new Date(task.dueAt); taskDueDate.setHours(0, 0, 0, 0); - const isOverdue = taskDueDate < today; + const isOverdue = taskDueDate < todayForFilter; logger.debug('[TWENTY_CRM_TASKS] Task date check', { id: task.id, dueAt: task.dueAt, taskDueDate: taskDueDate.toISOString(), - today: today.toISOString(), + today: todayForFilter.toISOString(), isOverdue, });