mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Gestion multi-profil multi-école
This commit is contained in:
@ -39,47 +39,61 @@ export default function DashboardPage() {
|
||||
|
||||
|
||||
const [classes, setClasses] = useState([]);
|
||||
|
||||
const [establishmentId, setEstablishmentId] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch data for classes
|
||||
fetchClasses().then(data => {
|
||||
setClasses(data);
|
||||
logger.info('Classes fetched:', data);
|
||||
const nbMaxStudents = data.reduce((acc, classe) => acc + classe.number_of_students, 0);
|
||||
const nbStudents = data.reduce((acc, classe) => acc + classe.students.length, 0);
|
||||
setStructureCapacity(nbMaxStudents);
|
||||
setTotalStudents(nbStudents);
|
||||
|
||||
getSession()
|
||||
.then(session => {
|
||||
if (session && session.user) {
|
||||
setEstablishmentId(session.user.establishment);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Error fetching classes:', error);
|
||||
.catch(err => {
|
||||
logger.error('Error fetching session:', err);
|
||||
});
|
||||
}, []);
|
||||
|
||||
fetchRegisterForms().then(data => {
|
||||
logger.info('Pending registrations fetched:', data);
|
||||
setPendingRegistration(data.count);
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Error fetching pending registrations:', error);
|
||||
});
|
||||
useEffect(() => {
|
||||
if (establishmentId) {
|
||||
// Fetch data for classes
|
||||
fetchClasses(establishmentId).then(data => {
|
||||
setClasses(data);
|
||||
logger.info('Classes fetched:', data);
|
||||
const nbMaxStudents = data.reduce((acc, classe) => acc + classe.number_of_students, 0);
|
||||
const nbStudents = data.reduce((acc, classe) => acc + classe.students.length, 0);
|
||||
setStructureCapacity(nbMaxStudents);
|
||||
setTotalStudents(nbStudents);
|
||||
|
||||
fetchUpcomingEvents().then(data => {
|
||||
setUpcomingEvents(data);
|
||||
}).catch(error => {
|
||||
logger.error('Error fetching upcoming events:', error);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Error fetching classes:', error);
|
||||
});
|
||||
|
||||
// Simulation de chargement des données
|
||||
setTimeout(() => {
|
||||
setMonthlyStats({
|
||||
inscriptions: [150, 180, 210, 245],
|
||||
completionRate: 78
|
||||
});
|
||||
setIsLoading(false);
|
||||
}, 1000);
|
||||
}
|
||||
, []);
|
||||
fetchRegisterForms().then(data => {
|
||||
logger.info('Pending registrations fetched:', data);
|
||||
setPendingRegistration(data.count);
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Error fetching pending registrations:', error);
|
||||
});
|
||||
|
||||
fetchUpcomingEvents().then(data => {
|
||||
setUpcomingEvents(data);
|
||||
}).catch(error => {
|
||||
logger.error('Error fetching upcoming events:', error);
|
||||
});
|
||||
|
||||
// Simulation de chargement des données
|
||||
setTimeout(() => {
|
||||
setMonthlyStats({
|
||||
inscriptions: [150, 180, 210, 245],
|
||||
completionRate: 78
|
||||
});
|
||||
setIsLoading(false);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
, [establishmentId]);
|
||||
|
||||
|
||||
if (isLoading) return <Loader />;
|
||||
|
||||
Reference in New Issue
Block a user