diff --git a/src/components/MainDrawer.tsx b/src/components/MainDrawer.tsx index 3a09c0b1..fc8cbb18 100644 --- a/src/components/MainDrawer.tsx +++ b/src/components/MainDrawer.tsx @@ -9,10 +9,13 @@ import Drawer from '@/components/Drawer'; import Navbar from '@/components/Navbar'; import Button from '@/components/Button'; import SidebarMenu from '@/components/molecules/SidebarMenu'; +import PermissionNotFound from '@/components/helper/PermissionNotFound'; import { useUiStore } from '@/stores/ui/ui.store'; import { MAIN_DRAWER_LINKS } from '@/config/constant'; import { isPathActive } from '@/lib/helper'; +import { ROUTE_PERMISSIONS } from '@/config/route-permission'; +import { useAuth } from '@/services/hooks/useAuth'; const MainDrawerContent = () => { const pathname = usePathname(); @@ -62,6 +65,11 @@ const MainDrawer = ({ }>) => { const { mainDrawerOpen, setMainDrawerOpen } = useUiStore(); const pathname = usePathname(); + const { permissionCheck } = useAuth(); + + const isPermitted = ROUTE_PERMISSIONS[pathname]?.some((permission) => + permissionCheck(permission) + ); const getPageTitle = useCallback(() => { let title = ''; @@ -101,6 +109,10 @@ const MainDrawer = ({ setMainDrawerOpen(!mainDrawerOpen); }; + if (!isPermitted) { + return ; + } + return (