widget leantime refactor
This commit is contained in:
parent
9ff8c3ca7a
commit
6cce6d4269
@ -221,8 +221,11 @@ async function fetchTwentyTasks(): Promise<TwentyTask[]> {
|
||||
});
|
||||
|
||||
// Filter client-side for overdue tasks (dueAt < today) and not completed (status !== 'Done')
|
||||
const todayForFilter = new Date();
|
||||
todayForFilter.setHours(0, 0, 0, 0);
|
||||
// Use local date for comparison to avoid timezone issues
|
||||
const now = new Date();
|
||||
const todayYear = now.getFullYear();
|
||||
const todayMonth = now.getMonth();
|
||||
const todayDay = now.getDate();
|
||||
|
||||
const tasks: TwentyTask[] = allTasks
|
||||
.filter((task: TwentyTask) => {
|
||||
@ -237,15 +240,24 @@ async function fetchTwentyTasks(): Promise<TwentyTask[]> {
|
||||
return false; // Exclude tasks without due date
|
||||
}
|
||||
|
||||
// Parse the due date and compare dates (not times)
|
||||
// Use local date comparison to avoid timezone issues
|
||||
const taskDueDate = new Date(task.dueAt);
|
||||
taskDueDate.setHours(0, 0, 0, 0);
|
||||
// Get local date components (year, month, day) ignoring time
|
||||
const taskYear = taskDueDate.getFullYear();
|
||||
const taskMonth = taskDueDate.getMonth();
|
||||
const taskDay = taskDueDate.getDate();
|
||||
|
||||
const isOverdue = taskDueDate < todayForFilter;
|
||||
logger.debug('[TWENTY_CRM_TASKS] Task date check', {
|
||||
// Compare dates: task is overdue if its date is before today's date
|
||||
const isOverdue = taskYear < todayYear ||
|
||||
(taskYear === todayYear && taskMonth < todayMonth) ||
|
||||
(taskYear === todayYear && taskMonth === todayMonth && taskDay < todayDay);
|
||||
|
||||
logger.error('[TWENTY_CRM_TASKS] Task date check', {
|
||||
id: task.id,
|
||||
dueAt: task.dueAt,
|
||||
taskDueDate: taskDueDate.toISOString(),
|
||||
today: todayForFilter.toISOString(),
|
||||
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')}`,
|
||||
isOverdue,
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user