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();