import { useState, useEffect, useCallback } from 'react'; // @mui import Collapse from '@mui/material/Collapse'; // routes import { usePathname } from 'src/routes/hooks'; import { useActiveLink } from 'src/routes/hooks/use-active-link'; // import { NavListProps, NavConfigProps } from '../types'; import NavItem from './nav-item'; // ---------------------------------------------------------------------- type NavListRootProps = { data: NavListProps; depth: number; hasChild: boolean; config: NavConfigProps; }; export default function NavList({ data, depth, hasChild, config }: NavListRootProps) { const pathname = usePathname(); const active = useActiveLink(data.path, hasChild); const externalLink = data.path.includes('http'); const [open, setOpen] = useState(active); useEffect(() => { if (!active) { handleClose(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [pathname]); const handleToggle = useCallback(() => { setOpen((prev) => !prev); }, []); const handleClose = useCallback(() => { setOpen(false); }, []); return ( <> {hasChild && ( )} ); } // ---------------------------------------------------------------------- type NavListSubProps = { data: NavListProps[]; depth: number; config: NavConfigProps; }; function NavSubList({ data, depth, config }: NavListSubProps) { return ( <> {data.map((list) => ( ))} ); }