diff --git a/src/app/daily/DailyPageClient.tsx b/src/app/daily/DailyPageClient.tsx index ca4aae7..d8d359a 100644 --- a/src/app/daily/DailyPageClient.tsx +++ b/src/app/daily/DailyPageClient.tsx @@ -11,6 +11,7 @@ import { DailySection } from '@/components/daily/DailySection'; import { PendingTasksSection } from '@/components/daily/PendingTasksSection'; import { dailyClient } from '@/clients/daily-client'; import { Header } from '@/components/ui/Header'; +import { DeadlineReminder } from '@/components/daily/DeadlineReminder'; import { getPreviousWorkday, formatDateLong, isToday, generateDateTitle, formatDateShort, isYesterday } from '@/lib/date-utils'; interface DailyPageClientProps { @@ -211,8 +212,13 @@ export function DailyPageClient({ + {/* Rappel des échéances urgentes - Desktop uniquement */} +
+ +
+ {/* Contenu principal */} -
+
{/* Layout Mobile uniquement - Section Aujourd'hui en premier */}
{dailyView && ( diff --git a/src/components/daily/DeadlineReminder.tsx b/src/components/daily/DeadlineReminder.tsx new file mode 100644 index 0000000..de94b52 --- /dev/null +++ b/src/components/daily/DeadlineReminder.tsx @@ -0,0 +1,120 @@ +'use client'; + +import { useState, useEffect, useTransition } from 'react'; +import { DeadlineTask } from '@/services/analytics/deadline-analytics'; +import { getDeadlineMetrics } from '@/actions/deadline-analytics'; +import { Card } from '@/components/ui/Card'; + +export function DeadlineReminder() { + const [urgentTasks, setUrgentTasks] = useState([]); + const [error, setError] = useState(null); + const [isPending, startTransition] = useTransition(); + + useEffect(() => { + const loadUrgentTasks = () => { + startTransition(async () => { + try { + setError(null); + const response = await getDeadlineMetrics(); + + if (response.success && response.data) { + // Combiner toutes les tâches urgentes et trier par urgence + const combinedTasks = [ + ...response.data.overdue, + ...response.data.critical, + ...response.data.warning + ].sort((a, b) => { + // En retard d'abord, puis critique, puis attention + const urgencyOrder: Record = { 'overdue': 0, 'critical': 1, 'warning': 2 }; + if (urgencyOrder[a.urgencyLevel] !== urgencyOrder[b.urgencyLevel]) { + return urgencyOrder[a.urgencyLevel] - urgencyOrder[b.urgencyLevel]; + } + // Si même urgence, trier par jours restants + return a.daysRemaining - b.daysRemaining; + }); + + setUrgentTasks(combinedTasks); + } else { + setError(response.error || 'Erreur lors du chargement des échéances'); + } + } catch (err) { + setError(err instanceof Error ? err.message : 'Erreur lors du chargement des échéances'); + console.error('Erreur échéances:', err); + } + }); + }; + + loadUrgentTasks(); + }, []); + + const getUrgencyIcon = (task: DeadlineTask) => { + if (task.urgencyLevel === 'overdue') return '🔴'; + if (task.urgencyLevel === 'critical') return '🟠'; + return '🟡'; + }; + + const getUrgencyText = (task: DeadlineTask) => { + if (task.urgencyLevel === 'overdue') { + return task.daysRemaining === -1 ? 'En retard de 1 jour' : `En retard de ${Math.abs(task.daysRemaining)} jours`; + } else if (task.urgencyLevel === 'critical') { + return task.daysRemaining === 0 ? 'Échéance aujourd\'hui' : + task.daysRemaining === 1 ? 'Échéance demain' : + `Dans ${task.daysRemaining} jours`; + } else { + return `Dans ${task.daysRemaining} jours`; + } + }; + + const getSourceIcon = (source: string) => { + switch (source) { + case 'jira': return '🔗'; + case 'reminder': return '📱'; + default: return '📋'; + } + }; + + // Ne rien afficher si pas de tâches urgentes ou si en cours de chargement + if (isPending || error || urgentTasks.length === 0) { + return null; + } + + return ( + +
+
⚠️
+
+

+ Rappel - Tâches urgentes ({urgentTasks.length}) +

+ +
+ {urgentTasks.map((task, index) => ( +
+ {getUrgencyIcon(task)} + + {task.title} + + + ({getUrgencyText(task)}) + + + {getSourceIcon(task.source)} + + {index < urgentTasks.length - 1 && ( + + )} +
+ ))} +
+ +
+ Consultez la page d'accueil pour plus de détails sur les échéances +
+
+
+
+ ); +}