widget leantime refactor

This commit is contained in:
alma 2026-01-15 22:55:30 +01:00
parent c66c44c91a
commit 9ff8c3ca7a

View File

@ -43,9 +43,9 @@ async function fetchTwentyTasks(): Promise<TwentyTask[]> {
: `${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<TwentyTask[]> {
});
// 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<TwentyTask[]> {
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,
});