From 301d7082631a6dec6e25617578ceda19218fb11f Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 23:01:09 +0200 Subject: [PATCH] working leantime widget 121 --- components/flow.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/flow.tsx b/components/flow.tsx index 94ccce38..f11d5abf 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -81,10 +81,16 @@ export function Flow() { }; const getValidDate = (task: Task): string | null => { - // Only use dateToFinish + // First check dateToFinish if (task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00') { return task.dateToFinish; } + + // Then check date + if (task.date && task.date !== '0000-00-00 00:00:00') { + return task.date; + } + return null; }; @@ -100,7 +106,7 @@ export function Flow() { return; } - // Filter out completed tasks (status 3) and sort by dateToFinish + // Filter out completed tasks (status 3) and sort by date const sortedTasks = data .filter((task: Task) => task.status !== 3) .sort((a: Task, b: Task) => { @@ -114,7 +120,7 @@ export function Flow() { return new Date(dateA).getTime() - new Date(dateB).getTime(); }); - console.log('Sorted tasks by dateToFinish:', sortedTasks); + console.log('Sorted tasks:', sortedTasks); setTasks(sortedTasks.slice(0, 6)); } catch (error) { console.error('Error fetching tasks:', error);