diff --git a/src/components/Layout/Sidebar.jsx b/src/components/Layout/Sidebar.jsx index 807cfa8..c29039c 100644 --- a/src/components/Layout/Sidebar.jsx +++ b/src/components/Layout/Sidebar.jsx @@ -14,13 +14,27 @@ const Sidebar = ({ collapsed }) => { const { isDarkMode } = useTheme(); const { user } = useAuth(); + const getSelectedKeys = useMemo(() => { + const pathname = location.pathname.substring(1); + + const pathParts = pathname.split('/'); + let key = ''; + + if (pathParts.length >= 2) { + const baseKey = `${pathParts[0]}/${pathParts[1]}`; + key = pathname.includes('/') ? baseKey : pathname; + } else { + key = pathname; + } + + return [key]; + }, [location.pathname]); + const menuClient = useMemo(() => { - if (!user?.id||user.menukeys?.length===0) return []; + if (!user?.id || user.menukeys?.length === 0) return []; return getMenuItems(user?.menukeys || []); }, [user]); -useEffect(()=>{ - console.log(menuClient,'menuClient'); -},[menuClient]) + const defaultOpenKeys = useMemo(() => { const pathSegments = location.pathname.split("/").filter(Boolean); return pathSegments.reduce((acc, _, index) => { @@ -48,7 +62,7 @@ useEffect(()=>{ (