From f3ead86bde8f8e6a4ce9f3732696af791b790768 Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 19:33:21 +0200 Subject: [PATCH] working leantime widget 71 --- app/api/leantime/tasks/route.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/api/leantime/tasks/route.ts b/app/api/leantime/tasks/route.ts index 1f313e30..5cff97f8 100644 --- a/app/api/leantime/tasks/route.ts +++ b/app/api/leantime/tasks/route.ts @@ -160,15 +160,23 @@ export async function GET(request: NextRequest) { status: task.status }); + // Skip completed tasks (status 3) + if (task.status === 3) { + return false; + } + // Convert both to strings for comparison to handle any type mismatches const taskEditorId = String(task.editorId).trim(); const currentUserId = String(userId).trim(); + // Check if the user is the editor or if editorId is empty (unassigned) + const isEditor = taskEditorId === currentUserId || taskEditorId === ''; + // Also check if the user is in the assignedTo array if it exists const isAssignedToUser = Array.isArray(task.assignedTo) && task.assignedTo.some((id: any) => String(id).trim() === currentUserId); - return taskEditorId === currentUserId || isAssignedToUser; + return isEditor || isAssignedToUser; }) .map((task: any) => ({ id: task.id.toString(),