working leantime widget 91

This commit is contained in:
Alma 2025-04-12 20:48:55 +02:00
parent 36a0d3ca19
commit 237451c41d

View File

@ -89,11 +89,12 @@ export function Flow() {
return; return;
} }
// Sort tasks by due date (oldest first) // Filter tasks with valid due dates and sort them
const sortedTasks = data.tasks const sortedTasks = data.tasks
.filter((task: Task) => task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00')
.sort((a: Task, b: Task) => { .sort((a: Task, b: Task) => {
const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() : new Date(a.date).getTime(); const dateA = new Date(a.dateToFinish).getTime();
const dateB = b.dateToFinish ? new Date(b.dateToFinish).getTime() : new Date(b.date).getTime(); const dateB = new Date(b.dateToFinish).getTime();
return dateA - dateB; return dateA - dateB;
}) })
.slice(0, 6); // Limit to 6 tasks .slice(0, 6); // Limit to 6 tasks
@ -113,51 +114,56 @@ export function Flow() {
}, []); }, []);
return ( return (
<Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/80 backdrop-blur-sm"> <Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg">
<CardHeader className="flex flex-row items-center justify-between pb-2"> <CardHeader className="flex flex-row items-center justify-between pb-2 border-b border-gray-100">
<CardTitle className="text-2xl font-bold">Flow</CardTitle> <CardTitle className="text-xl font-semibold text-gray-800">Flow</CardTitle>
<Button <Button
variant="ghost" variant="ghost"
size="icon" size="icon"
onClick={() => fetchTasks()} onClick={() => fetchTasks()}
className="h-8 w-8 p-0 hover:bg-gray-100/50 rounded-full" className="h-8 w-8 p-0 hover:bg-gray-100/50 rounded-full"
> >
<RefreshCw className="h-4 w-4" /> <RefreshCw className="h-4 w-4 text-gray-600" />
</Button> </Button>
</CardHeader> </CardHeader>
<CardContent className="space-y-4"> <CardContent className="p-4">
{loading ? ( {loading ? (
<div className="flex items-center justify-center py-4"> <div className="flex items-center justify-center py-8">
<div className="h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent" /> <div className="h-5 w-5 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
</div> </div>
) : error ? ( ) : error ? (
<div className="text-sm text-red-500">{error}</div> <div className="text-sm text-red-500 text-center py-4">{error}</div>
) : tasks.length === 0 ? ( ) : tasks.length === 0 ? (
<div className="text-sm text-muted-foreground text-center">No tasks found</div> <div className="text-sm text-gray-500 text-center py-8">No tasks with due dates found</div>
) : ( ) : (
<div className="space-y-2 max-h-[400px] overflow-y-auto pr-2"> <div className="space-y-3 max-h-[460px] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent">
{tasks.map((task) => ( {tasks.map((task) => (
<div <div
key={task.id} key={task.id}
className="p-3 rounded-xl bg-white/90 shadow-sm hover:shadow-md transition-all duration-200" className="p-3 rounded-xl bg-white shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100"
> >
<div className="space-y-1"> <div className="flex gap-3">
<div className="flex-shrink-0 w-14 h-14 rounded-lg bg-blue-50 flex flex-col items-center justify-center border border-blue-100">
<span className="text-xs text-blue-600 font-medium uppercase">
{new Date(task.dateToFinish).toLocaleDateString('fr-FR', { month: 'short' })}
</span>
<span className="text-lg text-blue-700 font-bold">
{new Date(task.dateToFinish).getDate()}
</span>
</div>
<div className="flex-1 min-w-0 space-y-1.5">
<a <a
href={`https://agilite.slm-lab.net/tickets/showTicket/${task.id}`} href={`https://agilite.slm-lab.net/tickets/showTicket/${task.id}`}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="text-blue-500 hover:text-blue-600 font-medium block text-base line-clamp-2" className="text-blue-600 hover:text-blue-700 font-medium block text-base line-clamp-2"
> >
{task.headline} {task.headline}
</a> </a>
<div className="flex items-center text-gray-500 text-xs"> <div className="flex items-center text-gray-500 text-xs bg-gray-50 px-2 py-1 rounded-md">
<Folder className="h-3 w-3 mr-1 opacity-70" /> <Folder className="h-3 w-3 mr-1.5 opacity-70" />
<span className="truncate">{task.projectName}</span> <span className="truncate">{task.projectName}</span>
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && ( </div>
<span className="ml-2">
Due: {new Date(task.dateToFinish).toLocaleDateString()}
</span>
)}
</div> </div>
</div> </div>
</div> </div>