working leantime widget 118

This commit is contained in:
Alma 2025-04-12 22:54:21 +02:00
parent 117a75eecb
commit 234b720f49

View File

@ -95,7 +95,7 @@ export function Flow() {
const data = await response.json(); const data = await response.json();
if (!Array.isArray(data)) { if (!Array.isArray(data)) {
console.warn('No tasks found in response', data as unknown); console.warn('No tasks found in response');
setTasks([]); setTasks([]);
return; return;
} }
@ -114,10 +114,11 @@ export function Flow() {
return new Date(dateA).getTime() - new Date(dateB).getTime(); return new Date(dateA).getTime() - new Date(dateB).getTime();
}); });
console.log('Sorted tasks by dateToFinish:', sortedTasks); // Only log the count of tasks for security
console.log('Number of tasks found:', sortedTasks.length);
setTasks(sortedTasks.slice(0, 6)); setTasks(sortedTasks.slice(0, 6));
} catch (error) { } catch (error) {
console.error('Error fetching tasks:', error); console.error('Error fetching tasks');
setError('Failed to fetch tasks'); setError('Failed to fetch tasks');
} finally { } finally {
setLoading(false); setLoading(false);
@ -133,8 +134,8 @@ export function Flow() {
if (!task.validDate) { if (!task.validDate) {
return ( return (
<> <>
<span className="text-xs text-gray-600 font-medium">NO</span> <span className="text-[10px] text-gray-600 font-medium">NO</span>
<span className="text-lg text-gray-700 font-bold">DATE</span> <span className="text-sm text-gray-700 font-bold">DATE</span>
</> </>
); );
} }
@ -146,23 +147,27 @@ export function Flow() {
try { try {
const month = task.validDate.toLocaleString('fr-FR', { month: 'short' }).toUpperCase(); const month = task.validDate.toLocaleString('fr-FR', { month: 'short' }).toUpperCase();
const day = task.validDate.getDate(); const day = task.validDate.getDate();
const year = task.validDate.getFullYear();
return ( return (
<> <>
<span className={`text-xs font-medium uppercase ${isPastDue ? 'text-red-600' : 'text-blue-600'}`}> <span className={`text-[10px] font-medium uppercase ${isPastDue ? 'text-red-600' : 'text-blue-600'}`}>
{month} {month}
</span> </span>
<span className={`text-lg font-bold ${isPastDue ? 'text-red-700' : 'text-blue-700'}`}> <span className={`text-sm font-bold ${isPastDue ? 'text-red-700' : 'text-blue-700'}`}>
{day} {day}
</span> </span>
<span className={`text-[8px] font-medium ${isPastDue ? 'text-red-600' : 'text-blue-600'}`}>
{year}
</span>
</> </>
); );
} catch (error) { } catch (error) {
console.error('Error formatting date for task', task.id, error); console.error('Error formatting date for task', task.id);
return ( return (
<> <>
<span className="text-xs text-gray-600 font-medium">ERR</span> <span className="text-[10px] text-gray-600 font-medium">ERR</span>
<span className="text-lg text-gray-700 font-bold">DATE</span> <span className="text-sm text-gray-700 font-bold">DATE</span>
</> </>
); );
} }
@ -170,48 +175,48 @@ export function Flow() {
return ( return (
<Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/95 backdrop-blur-sm border-0 shadow-lg"> <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 border-b border-gray-100"> <CardHeader className="flex flex-row items-center justify-between pb-2 border-b border-gray-100 space-y-0 pt-3 px-3">
<CardTitle className="text-xl font-semibold text-gray-800">Flow</CardTitle> <CardTitle className="text-lg 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-6 w-6 p-0 hover:bg-gray-100/50 rounded-full"
> >
<RefreshCw className="h-4 w-4 text-gray-600" /> <RefreshCw className="h-3 w-3 text-gray-600" />
</Button> </Button>
</CardHeader> </CardHeader>
<CardContent className="p-4"> <CardContent className="p-3">
{loading ? ( {loading ? (
<div className="flex items-center justify-center py-8"> <div className="flex items-center justify-center py-6">
<div className="h-5 w-5 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" /> <div className="h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
</div> </div>
) : error ? ( ) : error ? (
<div className="text-sm text-red-500 text-center py-4">{error}</div> <div className="text-xs text-red-500 text-center py-3">{error}</div>
) : tasks.length === 0 ? ( ) : tasks.length === 0 ? (
<div className="text-sm text-gray-500 text-center py-8">No tasks with due dates found</div> <div className="text-xs text-gray-500 text-center py-6">No tasks with due dates found</div>
) : ( ) : (
<div className="space-y-3 max-h-[460px] overflow-y-auto pr-2 scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent"> <div className="space-y-2 max-h-[360px] 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 shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100" className="p-2 rounded-lg bg-white shadow-sm hover:shadow-md transition-all duration-200 border border-gray-100"
> >
<div className="flex gap-3"> <div className="flex gap-2">
<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"> <div className="flex-shrink-0 w-12 h-12 rounded-lg bg-blue-50 flex flex-col items-center justify-center border border-blue-100">
<TaskDate task={task} /> <TaskDate task={task} />
</div> </div>
<div className="flex-1 min-w-0 space-y-1.5"> <div className="flex-1 min-w-0 space-y-1">
<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-600 hover:text-blue-700 font-medium block text-base line-clamp-2" className="text-blue-600 hover:text-blue-700 font-medium block text-sm line-clamp-2"
> >
{task.headline} {task.headline}
</a> </a>
<div className="flex items-center text-gray-500 text-xs bg-gray-50 px-2 py-1 rounded-md"> <div className="flex items-center text-gray-500 text-[10px] bg-gray-50 px-1.5 py-0.5 rounded-md">
<Folder className="h-3 w-3 mr-1.5 opacity-70" /> <Folder className="h-2.5 w-2.5 mr-1 opacity-70" />
<span className="truncate">{task.projectName}</span> <span className="truncate">{task.projectName}</span>
</div> </div>
</div> </div>