diff --git a/app/api/leantime/tasks/route.ts b/app/api/leantime/tasks/route.ts index 75fecaf2..b286c43c 100644 --- a/app/api/leantime/tasks/route.ts +++ b/app/api/leantime/tasks/route.ts @@ -152,9 +152,15 @@ export async function GET(request: NextRequest) { const tasks = data.result .filter((task: any) => { - // Skip all completed tasks (status 5), whether they are main tasks or subtasks - if (task.status === 5) { - console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'})`); + // Convert status to number to ensure consistent comparison + const taskStatus = Number(task.status); + + // Log the raw status value for debugging + console.log(`Raw task ${task.id} status: ${task.status}, converted: ${taskStatus}`); + + // Skip tasks that are done (status 3 or 5) + if (taskStatus === 3 || taskStatus === 5) { + console.log(`Filtering out completed task ${task.id} (type: ${task.type || 'main'}, status: ${taskStatus})`); return false; } @@ -164,7 +170,7 @@ export async function GET(request: NextRequest) { // Only show tasks where the user is the editor const isUserEditor = taskEditorId === currentUserId; - console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`); + console.log(`Task ${task.id}: status=${taskStatus}, type=${task.type || 'main'}, isUserEditor=${isUserEditor}`); return isUserEditor; }) .map((task: any) => ({ @@ -172,7 +178,7 @@ export async function GET(request: NextRequest) { headline: task.headline, projectName: task.projectName, projectId: task.projectId, - status: task.status, + status: Number(task.status), // Ensure status is a number dateToFinish: task.dateToFinish || null, milestone: task.type || null, details: task.description || null, @@ -181,7 +187,7 @@ export async function GET(request: NextRequest) { editorId: task.editorId, editorFirstname: task.editorFirstname, editorLastname: task.editorLastname, - type: task.type || null // Added type field to identify subtasks + type: task.type || null })); console.log(`Found ${tasks.length} tasks assigned to user ${userId}`); diff --git a/components/flow.tsx b/components/flow.tsx index 8ab2e328..337b74f9 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -105,12 +105,13 @@ export function Duties() { return; } - // Filter out all tasks and subtasks with status 5 (Done) and sort by dateToFinish + // Filter out all tasks with done status (3 or 5) and sort by dateToFinish const sortedTasks = data .filter((task: Task) => { - const isNotDone = task.status !== 5; + const status = Number(task.status); + const isNotDone = status !== 3 && status !== 5; // Log task details for debugging - console.log(`Task ${task.id}: status=${task.status}, type=${task.type || 'main'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`); + console.log(`Task ${task.id}: status=${status}, type=${task.type || 'main'}, dateToFinish=${task.dateToFinish}, isNotDone=${isNotDone}`); return isNotDone; }) .sort((a: Task, b: Task) => {