fix: correction de l'ouverture du dashbord [#39]

This commit is contained in:
Luc SORIGNET
2025-04-07 20:09:10 +02:00
parent 839a26257b
commit a157d53932
4 changed files with 27 additions and 6 deletions

View File

@ -16,10 +16,10 @@ import { login } from '@/app/actions/authAction';
import { getSession } from 'next-auth/react';
import { useCsrfToken } from '@/context/CsrfContext'; // Importez le hook useCsrfToken
import logger from '@/utils/logger';
import { useSession } from 'next-auth/react';
import ProfileSelector from '@/components/ProfileSelector'; // Importez le composant ProfileSelector
import { RIGHTS } from '@/utils/rights';
import { setCurrentRoleIndex } from '@/store/Store';
const useFakeData = process.env.NEXT_PUBLIC_USE_FAKE_DATA === 'true';
export default function Page() {
const searchParams = useSearchParams();
@ -63,9 +63,12 @@ export default function Page() {
if (roles.length > 0) {
// Redirection en fonction du rôle
// Ne pas désactiver le loader avant la redirection
if (roles[0].role_type === 1) {
const currentRoleIndex = 0;
setCurrentRoleIndex(currentRoleIndex);
const role = roles[currentRoleIndex].role_type;
if (role === RIGHTS.ADMIN || role === RIGHTS.TEACHER) {
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
} else if (roles[0].role_type === 2) {
} else if (role === RIGHTS.PARENT) {
router.push(FE_PARENTS_HOME_URL);
} else {
setIsLoading(false);