From 65b7b3ab1110e4acaa3ff13c5e7658f5009804d3 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Wed, 29 May 2024 14:54:47 +0200 Subject: [PATCH] fix right access --- src/components/admin/NewAdminNavigation.tsx | 2 +- src/pages/admin/newportal/manage/access/index.tsx | 8 ++++++++ src/pages/admin/newportal/manage/activities/index.tsx | 8 ++++++++ .../admin/newportal/manage/settings/archive/index.tsx | 8 ++++++++ src/pages/admin/newportal/manage/settings/index.tsx | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/components/admin/NewAdminNavigation.tsx b/src/components/admin/NewAdminNavigation.tsx index 43aa856ce..d2946f9d9 100644 --- a/src/components/admin/NewAdminNavigation.tsx +++ b/src/components/admin/NewAdminNavigation.tsx @@ -57,7 +57,7 @@ export const NewAdminNavigation = () => { const [selectedTab, setSelectedTab] = React.useState('Créer'); const tabs: Tab[] = [ - { path: '/admin/newportal/create', label: 'Créer', Icon: CreerIcon, rights: [UserType.ADMIN] }, + { path: '/admin/newportal/create', label: 'Créer', Icon: CreerIcon, rights: [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR] }, { path: '/admin/newportal/publish', label: 'Publier', Icon: PublierIcon, rights: [UserType.ADMIN] }, { path: '/admin/newportal/manage', label: 'Gérer', Icon: GererIcon, rights: [UserType.ADMIN] }, { path: '/admin/newportal/analyze', label: 'Analyser', Icon: AnalyserIcon, rights: [UserType.ADMIN, UserType.OBSERVATOR, UserType.MEDIATOR] }, diff --git a/src/pages/admin/newportal/manage/access/index.tsx b/src/pages/admin/newportal/manage/access/index.tsx index 9ce19a002..f915f958b 100644 --- a/src/pages/admin/newportal/manage/access/index.tsx +++ b/src/pages/admin/newportal/manage/access/index.tsx @@ -1,9 +1,17 @@ import Link from 'next/link'; import React from 'react'; +import { UserContext } from 'src/contexts/userContext'; import BackArrow from 'src/svg/back-arrow.svg'; +import { UserType } from 'types/user.type'; const Access = () => { + const { user } = React.useContext(UserContext); + const hasAccess = user?.type === UserType.SUPER_ADMIN; + + if (!hasAccess) { + return

Vous n'avez pas accès à cette page, vous devez être super admin.

; + } return (
diff --git a/src/pages/admin/newportal/manage/activities/index.tsx b/src/pages/admin/newportal/manage/activities/index.tsx index 794ac9005..273be2ae5 100644 --- a/src/pages/admin/newportal/manage/activities/index.tsx +++ b/src/pages/admin/newportal/manage/activities/index.tsx @@ -1,9 +1,17 @@ import Link from 'next/link'; import React from 'react'; +import { UserContext } from 'src/contexts/userContext'; import BackArrow from 'src/svg/back-arrow.svg'; +import { UserType } from 'types/user.type'; const Activities = () => { + const { user } = React.useContext(UserContext); + const hasAccess = user?.type === UserType.SUPER_ADMIN; + + if (!hasAccess) { + return

Vous n'avez pas accès à cette page, vous devez être super admin.

; + } return (
diff --git a/src/pages/admin/newportal/manage/settings/archive/index.tsx b/src/pages/admin/newportal/manage/settings/archive/index.tsx index b43ddfefe..770613ea3 100644 --- a/src/pages/admin/newportal/manage/settings/archive/index.tsx +++ b/src/pages/admin/newportal/manage/settings/archive/index.tsx @@ -1,9 +1,17 @@ import Link from 'next/link'; import React from 'react'; +import { UserContext } from 'src/contexts/userContext'; import BackArrow from 'src/svg/back-arrow.svg'; +import { UserType } from 'types/user.type'; const Archive = () => { + const { user } = React.useContext(UserContext); + const hasAccess = user?.type === UserType.SUPER_ADMIN; + + if (!hasAccess) { + return

Vous n'avez pas accès à cette page, vous devez être super admin.

; + } return (
diff --git a/src/pages/admin/newportal/manage/settings/index.tsx b/src/pages/admin/newportal/manage/settings/index.tsx index 5ba3553cf..446b54454 100644 --- a/src/pages/admin/newportal/manage/settings/index.tsx +++ b/src/pages/admin/newportal/manage/settings/index.tsx @@ -24,7 +24,7 @@ const Gerer = () => { const links: Link[] = [ { name: 'Archiver', link: '/admin/newportal/manage/settings/archive', rights: [UserType.SUPER_ADMIN] }, - { name: 'Présenatation de Pélico', link: '/admin/newportal/manage/settings/pelico', rights: [UserType.ADMIN, UserType.SUPER_ADMIN] }, + { name: 'Présentation de Pélico', link: '/admin/newportal/manage/settings/pelico', rights: [UserType.ADMIN, UserType.SUPER_ADMIN] }, { name: 'Paramétrer la home', link: '/admin/newportal/manage/settings/home', rights: [UserType.ADMIN, UserType.SUPER_ADMIN] }, { name: 'Paramétrer les phases', link: '/admin/newportal/manage/settings/phases', rights: [UserType.ADMIN, UserType.SUPER_ADMIN] }, ];