mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
chore: Ajout des présences dans le dashboard
This commit is contained in:
@ -7,10 +7,15 @@ import ClasseDetails from '@/components/ClasseDetails';
|
||||
import { fetchClasses } from '@/app/actions/schoolAction';
|
||||
import StatCard from '@/components/StatCard';
|
||||
import logger from '@/utils/logger';
|
||||
import { fetchRegisterForms } from '@/app/actions/subscriptionAction';
|
||||
import {
|
||||
fetchRegisterForms,
|
||||
fetchAbsences,
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
import { fetchUpcomingEvents } from '@/app/actions/planningAction';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import { useNotification } from '@/context/NotificationContext';
|
||||
import Attendance from '@/components/Grades/Attendance';
|
||||
|
||||
// Composant EventCard pour afficher les événements
|
||||
const EventCard = ({ title, date, description, type }) => (
|
||||
<div className="bg-stone-50 p-4 rounded-lg shadow-sm border border-gray-100 mb-4">
|
||||
@ -38,6 +43,7 @@ export default function DashboardPage() {
|
||||
});
|
||||
|
||||
const [classes, setClasses] = useState([]);
|
||||
const [absencesToday, setAbsencesToday] = useState([]);
|
||||
const { selectedEstablishmentId, selectedEstablishmentTotalCapacity } =
|
||||
useEstablishment();
|
||||
const { showNotification } = useNotification();
|
||||
@ -90,6 +96,27 @@ export default function DashboardPage() {
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error fetching upcoming events:', error);
|
||||
});
|
||||
|
||||
// Fetch absences/retards du jour
|
||||
fetchAbsences(selectedEstablishmentId)
|
||||
.then((data) => {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const absToday = (data || []).filter((a) => a.day === today);
|
||||
// Mapping pour Attendance
|
||||
setAbsencesToday(
|
||||
absToday.map((a) => ({
|
||||
id: a.id,
|
||||
date: a.day,
|
||||
type: [1, 2].includes(a.reason) ? 'Absence' : 'Retard',
|
||||
justified: [1, 3].includes(a.reason),
|
||||
commentaire: a.commentaire,
|
||||
student_name: a.student_name,
|
||||
}))
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Erreur lors du fetch des absences du jour:', error);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false); // Fin du chargement
|
||||
@ -137,7 +164,7 @@ export default function DashboardPage() {
|
||||
{t('inscriptionTrends')}
|
||||
</h2>
|
||||
{/* Insérer ici un composant de graphique */}
|
||||
<div className="h-64 bg-gray-50 rounded flex items-center justify-center">
|
||||
<div className="h-64 bg-gray-50 rounded flex items-center justify-center mb-6">
|
||||
<TrendingUp size={48} className="text-gray-300" />
|
||||
</div>
|
||||
</div>
|
||||
@ -150,6 +177,9 @@ export default function DashboardPage() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Ajout du composant Attendance en dessous, en lecture seule */}
|
||||
<Attendance absences={absencesToday} readOnly={true} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user