From 243e88f39879e94941742dd944dd442cd83ed73c Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 24 Jan 2026 13:20:23 +0100 Subject: [PATCH] Widget Devoir Finition --- app/api/leantime/tasks/route.ts | 9 ++++++--- components/flow.tsx | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/api/leantime/tasks/route.ts b/app/api/leantime/tasks/route.ts index daced92..82d5519 100644 --- a/app/api/leantime/tasks/route.ts +++ b/app/api/leantime/tasks/route.ts @@ -105,7 +105,8 @@ export async function GET(request: NextRequest) { const taskStatus = task.status; if (taskStatus !== null && taskStatus !== undefined) { const statusNum = typeof taskStatus === 'string' ? parseInt(taskStatus, 10) : taskStatus; - if (statusNum === 5 || taskStatus === '5' || taskStatus === 'Done' || taskStatus === 'done' || taskStatus === 'DONE') { + // In Leantime: status 3 = DONE, also check status 5 + if (statusNum === 3 || statusNum === 5 || taskStatus === '3' || taskStatus === '5' || taskStatus === 'Done' || taskStatus === 'done' || taskStatus === 'DONE') { logger.debug('[LEANTIME_TASKS] Filtering out done task from cache', { id: task.id, headline: task.headline, @@ -206,13 +207,15 @@ export async function GET(request: NextRequest) { const tasks = data.result .filter((task: any) => { - // Filter out any task (main or subtask) that has status Done (5) + // Filter out any task (main or subtask) that has status Done + // In Leantime: status 3 = DONE (see status-labels/route.ts) + // Also check for status 5 as fallback // Handle both number and string formats, and check for null/undefined const taskStatus = task.status; if (taskStatus !== null && taskStatus !== undefined) { const statusNum = typeof taskStatus === 'string' ? parseInt(taskStatus, 10) : taskStatus; const statusStr = typeof taskStatus === 'string' ? taskStatus.trim().toLowerCase() : String(taskStatus).trim().toLowerCase(); - const isDone = statusNum === 5 || statusStr === '5' || statusStr === 'done'; + const isDone = statusNum === 3 || statusNum === 5 || statusStr === '3' || statusStr === '5' || statusStr === 'done'; if (isDone) { logger.debug('[LEANTIME_TASKS] Filtering out done task', { diff --git a/components/flow.tsx b/components/flow.tsx index 366a667..5407331 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -231,14 +231,15 @@ export function Duties() { const todayDay = now.getDate(); const filteredTasks = allTasks.filter((task: Task) => { - // Exclude tasks with status Done (5) - check both number and string formats + // Exclude tasks with status Done + // In Leantime: status 3 = DONE (see api/leantime/status-labels/route.ts), also check status 5 const rawStatus = (task as any).status; // Use any to handle potential string/number mismatch if (rawStatus === null || rawStatus === undefined) { // If status is null/undefined, keep the task (let other filters handle it) } else { const taskStatus = typeof rawStatus === 'string' ? parseInt(rawStatus, 10) : rawStatus; const statusStr = typeof rawStatus === 'string' ? rawStatus.toLowerCase() : String(rawStatus).toLowerCase(); - if (taskStatus === 5 || statusStr === '5' || statusStr === 'done') { + if (taskStatus === 3 || taskStatus === 5 || statusStr === '3' || statusStr === '5' || statusStr === 'done') { console.log('[Devoirs Widget] Filtering out done task:', { id: task.id, headline: task.headline,