'use client'; import { usePathname } from 'next/navigation'; import Image from 'next/image'; import { Icon } from '@iconify/react'; 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 { ROUTE_PERMISSIONS } from '@/config/route-permission'; import { useAuth } from '@/services/hooks/useAuth'; const MainDrawerContent = () => { const pathname = usePathname(); const { setMainDrawerOpen } = useUiStore(); const closeMainDrawerHandler = () => { setMainDrawerOpen(false); }; return (
LTI Logo

LTI ERP

Lumbung Telur Indonesia

); }; const MainDrawer = ({ children, }: Readonly<{ children: React.ReactNode; }>) => { const { mainDrawerOpen, setMainDrawerOpen } = useUiStore(); const pathname = usePathname(); const { permissionCheck } = useAuth(); const formattedPathname = pathname.endsWith('/') ? pathname : `${pathname}/`; const isPathnameNotFoundPage = formattedPathname === '/404/'; const isPermitted = ROUTE_PERMISSIONS[formattedPathname]?.some((permission) => permissionCheck(permission) ); const toggleSidebar = () => { setMainDrawerOpen(!mainDrawerOpen); }; if (!isPermitted && !isPathnameNotFoundPage) { return ; } if (isPathnameNotFoundPage) { return children; } return ( } className={{ drawerSide: 'border-r border-base-content/10', drawerSidebarContent: 'min-w-[244px] lg:w-[244px]', }} >
{children}
); }; export default MainDrawer;