From 767a0d56c75f8c540189fd4e53d4f6f44ab6e1fb Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 20:26:18 +0200 Subject: [PATCH] working leantime widget 81 --- components/flow.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/flow.tsx b/components/flow.tsx index c1c8afd0..518a2418 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -18,12 +18,9 @@ interface Task { date?: string; } -interface ProjectSummary { - name: string; - tasks: { - status: number; - count: number; - }[]; +interface ApiResponse { + jsonrpc: string; + result: Task[]; } export function Flow() { @@ -75,16 +72,19 @@ export function Flow() { if (!response.ok) { throw new Error('Failed to fetch tasks'); } - const data = await response.json(); + const data: ApiResponse = await response.json(); - if (!Array.isArray(data)) { - console.warn('No tasks found in response', data as unknown); + // Extract tasks from the result property + const tasksList = data.result || []; + + if (!Array.isArray(tasksList)) { + console.warn('No tasks found in response', tasksList); setTasks([]); return; } // Sort tasks by date and limit to 4 - const sortedTasks = data + const sortedTasks = tasksList .sort((a: Task, b: Task) => { const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() : a.date ? new Date(a.date).getTime() : Date.now();