From b9a6ce37485506365c0757f28c2dca8706503e54 Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 23:19:05 +0200 Subject: [PATCH] working leantime widget 130 --- components/flow.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/components/flow.tsx b/components/flow.tsx index 6096c4b4..784b48da 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -144,7 +144,8 @@ export function Flow() { // Update the TaskDate component to handle dates better const TaskDate = ({ task }: { task: TaskWithDate }) => { - if (!task.validDate) { + const dateStr = task.dateToFinish; + if (!dateStr || dateStr === '0000-00-00 00:00:00') { return ( <> NO @@ -153,13 +154,18 @@ export function Flow() { ); } - const today = new Date(); - today.setHours(0, 0, 0, 0); - const isPastDue = task.validDate < today; - try { - const month = task.validDate.toLocaleString('fr-FR', { month: 'short' }).toUpperCase(); - const day = task.validDate.getDate(); + const date = new Date(dateStr); + if (isNaN(date.getTime())) { + throw new Error('Invalid date'); + } + + const today = new Date(); + today.setHours(0, 0, 0, 0); + const isPastDue = date < today; + + const month = date.toLocaleString('fr-FR', { month: 'short' }).toUpperCase(); + const day = date.getDate(); return ( <>