From fc49d27b93c93559acd9222190bd3fecc5985632 Mon Sep 17 00:00:00 2001 From: Alma Date: Sat, 12 Apr 2025 19:04:34 +0200 Subject: [PATCH] working leantime widget 64 --- components/flow.tsx | 59 +++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/components/flow.tsx b/components/flow.tsx index a9b69362..f7fac7b3 100644 --- a/components/flow.tsx +++ b/components/flow.tsx @@ -6,28 +6,22 @@ import { Button } from "@/components/ui/button"; import { RefreshCw } from "lucide-react"; interface Task { - id: string; + id: number; headline: string; - projectName: string; - projectId: number; - status: number; - type: string; - dateToFinish: string; + description: string; date: string; - editFrom: string; - editTo: string; - editor: { - id: string; - firstname: string; - lastname: string; - }; - authorFirstname?: string; - authorLastname?: string; - tags?: string; - description?: string; - milestone?: string; - details?: string; - milestoneHeadline?: string; + dateToFinish: string; + projectId: number; + projectName: string; + type: string; + status: number; + editorId: string; + editorFirstname: string | null; + editorLastname: string | null; + authorFirstname: string; + authorLastname: string; + milestoneHeadline: string | null; + tags: string; } interface ProjectSummary { @@ -78,15 +72,11 @@ export function Flow() { }; const getDateToSort = (task: Task): number => { - // Try different date fields in order of preference - const dates = [ - task.dateToFinish, - task.date, - task.editTo, - task.editFrom - ].filter(date => date && date !== '0000-00-00 00:00:00'); - - return dates.length > 0 ? new Date(dates[0]).getTime() : Number.MAX_SAFE_INTEGER; + // Try to use dateToFinish first, then fall back to date + const dateStr = task.dateToFinish !== '0000-00-00 00:00:00' + ? task.dateToFinish + : task.date; + return new Date(dateStr).getTime(); }; const formatDate = (dateStr: string): string => { @@ -123,7 +113,7 @@ export function Flow() { .filter((task: Task) => task.headline && typeof task.headline === 'string' && - task.editor // Only show tasks with an editor + task.status !== 3 // Only show tasks that are not completed (status 3) ) .sort((a: Task, b: Task) => getDateToSort(a) - getDateToSort(b)); @@ -181,9 +171,14 @@ export function Flow() { Due: {formatDate(task.dateToFinish)}

)} - {task.editor && ( + {task.editorFirstname && task.editorLastname && (

- Assigned to: {task.editor.firstname} {task.editor.lastname} + Assigned to: {task.editorFirstname} {task.editorLastname} +

+ )} + {task.projectName && ( +

+ Project: {task.projectName}

)}