'use client'; import { Task } from '@/lib/types'; import { Card } from '@/components/ui/Card'; import { TagDisplay } from '@/components/ui/TagDisplay'; import { Badge } from '@/components/ui/Badge'; import { useTasksContext } from '@/contexts/TasksContext'; import { getPriorityConfig, getPriorityColorHex, getStatusBadgeClasses, getStatusLabel } from '@/lib/status-config'; import { TaskPriority } from '@/lib/types'; import Link from 'next/link'; interface RecentTasksProps { tasks: Task[]; } export function RecentTasks({ tasks }: RecentTasksProps) { const { tags: availableTags } = useTasksContext(); // Prendre les 5 tâches les plus récentes (créées ou modifiées) const recentTasks = tasks .sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) .slice(0, 5); // Fonctions simplifiées utilisant la configuration centralisée const getPriorityStyle = (priority: string) => { try { const config = getPriorityConfig(priority as TaskPriority); const hexColor = getPriorityColorHex(config.color); return { color: hexColor }; } catch { return { color: '#6b7280' }; // gray-500 par défaut } }; return (

Tâches Récentes

{recentTasks.length === 0 ? (

Aucune tâche disponible

Créez votre première tâche pour commencer

) : (
{recentTasks.map((task) => (

{task.title}

{task.source === 'jira' && ( Jira )}
{task.description && (

{task.description}

)}
{getStatusLabel(task.status)} {task.priority && ( {(() => { try { return getPriorityConfig(task.priority as TaskPriority).label; } catch { return task.priority; } })()} )} {task.tags && task.tags.length > 0 && (
{task.tags.length > 2 && ( +{task.tags.length - 2} )}
)}
{new Date(task.updatedAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
))}
)}
); }