working leantime widget 84

This commit is contained in:
Alma 2025-04-12 20:33:48 +02:00
parent 0ba915bddb
commit b038d48e7e

View File

@ -72,7 +72,7 @@ export function Flow() {
if (!response.ok) {
throw new Error('Failed to fetch tasks');
}
const data = await response.json();
const data: ApiResponse = await response.json();
// Extract tasks from the result property
const tasksList = data.result || [];
@ -83,9 +83,8 @@ export function Flow() {
return;
}
// Filter tasks with status 3 and sort by date
const filteredAndSortedTasks = tasksList
.filter((task: Task) => task.status === 3 && task.userId === 2)
// Sort tasks by date and limit to 4
const sortedTasks = tasksList
.sort((a: Task, b: Task) => {
const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() :
a.date ? new Date(a.date).getTime() : Date.now();
@ -95,8 +94,7 @@ export function Flow() {
})
.slice(0, 4); // Limit to 4 tasks
console.log('Filtered tasks:', filteredAndSortedTasks); // Debug log
setTasks(filteredAndSortedTasks);
setTasks(sortedTasks);
} catch (error) {
console.error('Error fetching tasks:', error);
setError('Failed to fetch tasks');
@ -112,7 +110,7 @@ export function Flow() {
return (
<Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/80 backdrop-blur-sm">
<CardHeader className="flex flex-row items-center justify-between pb-2">
<CardTitle className="text-2xl font-bold">Flow</CardTitle>
<CardTitle className="text-lg font-medium">Flow</CardTitle>
<Button
variant="ghost"
size="icon"
@ -132,18 +130,18 @@ export function Flow() {
) : tasks.length === 0 ? (
<div className="text-sm text-muted-foreground text-center">No tasks found</div>
) : (
<div className="space-y-3 max-h-[400px] overflow-y-auto pr-2">
<div className="space-y-2 max-h-[400px] overflow-y-auto pr-2">
{tasks.map((task) => (
<div
key={task.id}
className="p-3 rounded-xl bg-white/90 shadow-sm hover:shadow-md transition-all duration-200"
className="p-3 rounded-lg bg-white/90 shadow-sm hover:shadow-md transition-all duration-200"
>
<div className="space-y-1">
<a
href={`https://agilite.slm-lab.net/tickets/showTicket/${task.id}`}
target="_blank"
rel="noopener noreferrer"
className="text-blue-500 hover:text-blue-600 font-medium block text-sm"
className="text-sm text-blue-500 hover:text-blue-600 font-medium block truncate"
>
{task.headline}
</a>
@ -151,7 +149,7 @@ export function Flow() {
{task.projectName && (
<>
<Folder className="h-3 w-3 mr-1 opacity-70" />
<span>{task.projectName}</span>
<span className="truncate">{task.projectName}</span>
</>
)}
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && (