Skip to content

Commit

Permalink
feat(VIL-622): adding rights to admin and mediator to archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasambry committed Nov 18, 2024
1 parent fa9db91 commit 26c1bc2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/archive/archive.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const BASE_URL = '/api/archives';
export const useListArchives = () => {
const { user } = React.useContext(UserContext);

const hasAccess = user?.type === UserType.SUPER_ADMIN || user?.type === UserType.ADMIN || user?.type === UserType.MEDIATOR;
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR];

return useQuery(
['archives'],
Expand Down
2 changes: 1 addition & 1 deletion src/components/admin/NewAdminNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const NewAdminNavigation = () => {
const tabs: Tab[] = [
{ path: '/admin/newportal/create', label: 'Créer', Icon: CreerIcon, rights: [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR] },
{ path: '/admin/newportal/publier', label: 'Publier', Icon: PublierIcon, rights: [UserType.ADMIN, UserType.SUPER_ADMIN] },
{ path: '/admin/newportal/manage', label: 'Gérer', Icon: GererIcon, rights: [UserType.ADMIN, UserType.SUPER_ADMIN] },
{ path: '/admin/newportal/manage', label: 'Gérer', Icon: GererIcon, rights: [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR] },
{
path: '/admin/newportal/analyze',
label: 'Analyser',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/admin/newportal/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Link = {

const Gerer = () => {
const { user } = React.useContext(UserContext);
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN];
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR];

if (!hasAccess) {
return <h1>Vous n&apos;avez pas accès à cette page, vous devez être super admin.</h1>;
Expand All @@ -28,7 +28,7 @@ const Gerer = () => {
link: '/admin/newportal/manage/activities',
rights: [UserType.SUPER_ADMIN],
},
{ name: 'Paramétrer 1Village', link: '/admin/newportal/manage/settings', rights: [UserType.ADMIN, UserType.SUPER_ADMIN] },
{ name: 'Paramétrer 1Village', link: '/admin/newportal/manage/settings', rights: [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR] },
{ name: "Les droits d'accès", link: '/admin/newportal/manage/access', rights: [UserType.SUPER_ADMIN] },
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UserType } from 'types/user.type';

const Archive = () => {
const { user } = React.useContext(UserContext);
const hasAccess = user?.type === UserType.SUPER_ADMIN;
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR];
const [archives, setArchives] = useState<string[]>([]);
const { enqueueSnackbar } = useSnackbar();

Expand Down
4 changes: 2 additions & 2 deletions src/pages/admin/newportal/manage/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ type Link = {

const Gerer = () => {
const { user } = React.useContext(UserContext);
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN];
const hasAccess = user !== null && user.type in [UserType.ADMIN, UserType.SUPER_ADMIN, UserType.MEDIATOR];

if (!hasAccess) {
return <h1>Vous n&apos;avez pas accès à cette page, vous devez être modérateur ou super admin.</h1>;
}

const links: Link[] = [
{ name: 'Archiver', link: '/admin/newportal/manage/settings/archive', rights: [UserType.SUPER_ADMIN] },
{ name: 'Archiver', link: '/admin/newportal/manage/settings/archive', rights: [UserType.SUPER_ADMIN, UserType.ADMIN, UserType.MEDIATOR] },
{ 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] },
Expand Down

0 comments on commit 26c1bc2

Please sign in to comment.