mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-05 20:51:26 +00:00
fix: Réintégration du bouton de Bilan de compétence + harmonisation des paths d'upload de fichier
This commit is contained in:
@ -10,7 +10,8 @@ import {
|
||||
Pencil,
|
||||
Trash2,
|
||||
Save,
|
||||
Download
|
||||
Download,
|
||||
FileText,
|
||||
} from 'lucide-react';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
import Table from '@/components/Table';
|
||||
@ -435,6 +436,37 @@ export default function Page() {
|
||||
);
|
||||
};
|
||||
|
||||
const getBilanForStudent = (student) => {
|
||||
const bilans = Array.isArray(student?.bilans) ? student.bilans : [];
|
||||
if (!bilans.length) return null;
|
||||
|
||||
const currentPeriodStr = currentPeriodValue
|
||||
? getPeriodString(
|
||||
currentPeriodValue,
|
||||
selectedEstablishmentEvaluationFrequency,
|
||||
selectedSchoolYear
|
||||
)
|
||||
: null;
|
||||
|
||||
if (currentPeriodStr) {
|
||||
const exact = bilans.find(
|
||||
(bilan) => bilan?.period === currentPeriodStr && bilan?.file
|
||||
);
|
||||
if (exact) return exact;
|
||||
}
|
||||
|
||||
const schoolYearSuffix = `_${selectedSchoolYear}`;
|
||||
const sameYearBilans = bilans.filter(
|
||||
(bilan) => bilan?.file && bilan?.period?.endsWith(schoolYearSuffix)
|
||||
);
|
||||
|
||||
if (!sameYearBilans.length) return null;
|
||||
|
||||
return [...sameYearBilans].sort(
|
||||
(a, b) => new Date(b.created_at || 0) - new Date(a.created_at || 0)
|
||||
)[0];
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{ name: 'Photo', transform: () => null },
|
||||
{ name: 'Élève', transform: () => null },
|
||||
@ -510,8 +542,23 @@ export default function Page() {
|
||||
<span className="text-gray-400 text-xs">0</span>
|
||||
);
|
||||
case 'Actions':
|
||||
const bilan = getBilanForStudent(student);
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
{bilan?.file && (
|
||||
<a
|
||||
href={getSecureFileUrl(bilan.file)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-cyan-100 text-cyan-700 hover:bg-cyan-200 transition whitespace-nowrap"
|
||||
title={`Télécharger le bilan de compétences (${bilan.period})`}
|
||||
>
|
||||
<FileText size={14} />
|
||||
Bilan
|
||||
</a>
|
||||
)}
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
@ -70,7 +70,7 @@ export default function StudentCompetenciesPage() {
|
||||
'success',
|
||||
'Succès'
|
||||
);
|
||||
router.push(`/admin/grades/${studentId}`);
|
||||
router.push('/admin/grades');
|
||||
})
|
||||
.catch((error) => {
|
||||
showNotification(
|
||||
|
||||
Reference in New Issue
Block a user