diff --git a/components/flow.tsx b/components/flow.tsx index 1a2bdaf5..f1bddb7b 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -83,14 +83,14 @@ export function Flow() { } const data = await response.json(); - if (!Array.isArray(data)) { + if (!data.tasks || !Array.isArray(data.tasks)) { console.warn('No tasks found in response', data as unknown); setTasks([]); return; } // Sort tasks by due date (oldest first) - const sortedTasks = data + const sortedTasks = data.tasks .sort((a: Task, b: Task) => { const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() : new Date(a.date).getTime(); const dateB = b.dateToFinish ? new Date(b.dateToFinish).getTime() : new Date(b.date).getTime();