feat: Création d'un profile selector [#37,#38]

This commit is contained in:
Luc SORIGNET
2025-04-12 16:07:30 +02:00
parent 4c2e2f8756
commit 89b01b79db
16 changed files with 237 additions and 286 deletions

View File

@ -10,7 +10,7 @@ import logger from '@/utils/logger';
import { fetchRegisterForms } from '@/app/actions/subscriptionAction';
import { fetchUpcomingEvents } from '@/app/actions/planningAction';
import { getSession } from 'next-auth/react';
import { getCurrentRoleIndex } from '@/store/Store';
import { useEstablishment } from '@/context/EstablishmentContext';
// Composant EventCard pour afficher les événements
@ -42,14 +42,11 @@ export default function DashboardPage() {
const [classes, setClasses] = useState([]);
const [establishmentId, setEstablishmentId] = useState(null);
const { selectedEstablishmentId } = useEstablishment();
useEffect(() => {
getSession()
.then(session => {
if (session && session.user) {
const establishmentId = session.user.roles[getCurrentRoleIndex()].establishment__id;
setEstablishmentId(establishmentId);
}
setEstablishmentId(selectedEstablishmentId);
})
.catch(err => {
logger.error('Error fetching session:', err);