role akses admin
This commit is contained in:
@@ -7,6 +7,8 @@ import { NavListProps } from '../type';
|
||||
//
|
||||
import { NavItemRoot, NavItemSub } from './NavItem';
|
||||
import { getActive } from '..';
|
||||
import { accessGroup } from '@/layouts/dashboard/navbar/NavConfig';
|
||||
import useAuth from '@/hooks/useAuth';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -59,6 +61,7 @@ type NavListSubProps = {
|
||||
|
||||
function NavListSub({ list }: NavListSubProps) {
|
||||
const { pathname } = useLocation();
|
||||
const {user} = useAuth()
|
||||
|
||||
const active = getActive(list.path, pathname);
|
||||
|
||||
@@ -82,5 +85,15 @@ function NavListSub({ list }: NavListSubProps) {
|
||||
);
|
||||
}
|
||||
|
||||
return <NavItemSub item={list} active={active} />;
|
||||
if (accessGroup.admin.includes(list.path) && user?.role_id === 1) {
|
||||
return <NavItemSub item={list} active={active} />;
|
||||
}
|
||||
|
||||
if (!accessGroup.admin.includes(list.path)) {
|
||||
return <NavItemSub item={list} active={active} />;
|
||||
}
|
||||
|
||||
return <></>;
|
||||
|
||||
// return <NavItemSub item={list} active={active} />;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ const ICONS = {
|
||||
hospital: getIcon('ic_banking'),
|
||||
};
|
||||
|
||||
export const accessGroup = {
|
||||
admin: ["/report/logs"]
|
||||
}
|
||||
|
||||
const navConfig = [
|
||||
// GENERAL
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user