From 0ba915bddbcc78bf0b2906ca963662b0dfb062eb Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 20:31:24 +0200 Subject: [PATCH] working leantime widget 83 --- components/flow.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/flow.tsx b/components/flow.tsx index 40e96b5b..aaf3c821 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -73,13 +73,19 @@ export function Flow() { throw new Error('Failed to fetch tasks'); } const data = await response.json(); - - // Check if data is an array directly - const tasksList = Array.isArray(data) ? data : []; + // Extract tasks from the result property + const tasksList = data.result || []; + + if (!Array.isArray(tasksList)) { + console.warn('No tasks found in response', tasksList); + setTasks([]); + return; + } + // Filter tasks with status 3 and sort by date const filteredAndSortedTasks = tasksList - .filter((task: Task) => task.status === 3) + .filter((task: Task) => task.status === 3 && task.userId === 2) .sort((a: Task, b: Task) => { const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() : a.date ? new Date(a.date).getTime() : Date.now(); @@ -89,6 +95,7 @@ export function Flow() { }) .slice(0, 4); // Limit to 4 tasks + console.log('Filtered tasks:', filteredAndSortedTasks); // Debug log setTasks(filteredAndSortedTasks); } catch (error) { console.error('Error fetching tasks:', error);