working leantime widget 80

This commit is contained in:
Alma 2025-04-12 20:22:47 +02:00
parent f8e67958fd
commit fa733f952c

View File

@ -9,15 +9,13 @@ import { Badge } from "@/components/ui/badge";
interface Task {
id: number;
headline: string;
description?: string;
userId: number;
status: number;
editorId: string;
assignedTo?: any;
projectName?: string;
dateToFinish?: string;
date?: string;
projectId?: number;
projectName?: string;
status: number;
editorId?: string;
userId?: number;
assignedTo?: any;
}
interface ProjectSummary {
@ -85,9 +83,8 @@ export function Flow() {
return;
}
// Filter tasks with status 3 (In Progress) and sort by date
const filteredAndSortedTasks = data
.filter((task: Task) => task.status === 3)
// Sort tasks by date and limit to 4
const sortedTasks = data
.sort((a: Task, b: Task) => {
const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() :
a.date ? new Date(a.date).getTime() : Date.now();
@ -97,7 +94,7 @@ export function Flow() {
})
.slice(0, 4); // Limit to 4 tasks
setTasks(filteredAndSortedTasks);
setTasks(sortedTasks);
} catch (error) {
console.error('Error fetching tasks:', error);
setError('Failed to fetch tasks');
@ -148,17 +145,19 @@ export function Flow() {
>
{task.headline}
</a>
{task.projectName && (
<div className="flex items-center text-gray-500 text-xs">
<Folder className="h-3 w-3 mr-1 opacity-70" />
<span>{task.projectName}</span>
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && (
<span className="ml-2">
Due: {new Date(task.dateToFinish).toLocaleDateString()}
</span>
)}
</div>
)}
<div className="flex items-center text-gray-500 text-xs">
{task.projectName && (
<>
<Folder className="h-3 w-3 mr-1 opacity-70" />
<span>{task.projectName}</span>
</>
)}
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && (
<span className={task.projectName ? "ml-2" : ""}>
Due: {new Date(task.dateToFinish).toLocaleDateString()}
</span>
)}
</div>
</div>
</div>
))}