'use client'; import React, { useState } from 'react'; import { Trash2, Edit2, ClipboardList, ChevronDown, ChevronUp } from 'lucide-react'; import Button from '@/components/Form/Button'; import Popup from '@/components/Popup'; import { useNotification } from '@/context/NotificationContext'; export default function EvaluationList({ evaluations, onDelete, onEdit, onGradeStudents, }) { const [expandedId, setExpandedId] = useState(null); const [deletePopupVisible, setDeletePopupVisible] = useState(false); const [evaluationToDelete, setEvaluationToDelete] = useState(null); const { showNotification } = useNotification(); const handleDeleteClick = (evaluation) => { setEvaluationToDelete(evaluation); setDeletePopupVisible(true); }; const handleConfirmDelete = () => { if (evaluationToDelete && onDelete) { onDelete(evaluationToDelete.id) .then(() => { showNotification('Évaluation supprimée avec succès', 'success', 'Succès'); setDeletePopupVisible(false); setEvaluationToDelete(null); }) .catch((error) => { showNotification('Erreur lors de la suppression', 'error', 'Erreur'); }); } }; // Grouper les évaluations par matière const groupedBySpeciality = evaluations.reduce((acc, ev) => { const key = ev.speciality_name || 'Sans matière'; if (!acc[key]) { acc[key] = { name: key, color: ev.speciality_color || '#6B7280', evaluations: [], }; } acc[key].evaluations.push(ev); return acc; }, {}); if (evaluations.length === 0) { return (