// ** React Imports import { ElementType } from 'react' // ** Next Imports import Link from 'next/link' import { useRouter } from 'next/router' // ** MUI Imports import Chip from '@mui/material/Chip' import ListItem from '@mui/material/ListItem' import { styled } from '@mui/material/styles' import Typography from '@mui/material/Typography' import Box, { BoxProps } from '@mui/material/Box' import ListItemIcon from '@mui/material/ListItemIcon' import ListItemButton, { ListItemButtonProps } from '@mui/material/ListItemButton' // ** Configs Import import themeConfig from 'src/configs/themeConfig' // ** Types import { NavLink, NavGroup } from 'src/@core/layouts/types' import { Settings } from 'src/@core/context/settingsContext' // ** Custom Components Imports import UserIcon from 'src/layouts/components/UserIcon' import Translations from 'src/layouts/components/Translations' import CanViewNavLink from 'src/layouts/components/acl/CanViewNavLink' // ** Util Import import { handleURLQueries } from 'src/@core/layouts/utils' interface Props { parent?: boolean item: NavLink navHover?: boolean settings: Settings navVisible?: boolean collapsedNavWidth: number navigationBorderWidth: number toggleNavVisibility: () => void isSubToSub?: NavGroup | undefined } // ** Styled Components const MenuNavLink = styled(ListItemButton)< ListItemButtonProps & { component?: ElementType; href: string; target?: '_blank' | undefined } >(({ theme }) => ({ width: '100%', borderRadius: 8, transition: 'padding-left .25s ease-in-out', '&.active': { '&, &:hover': { backgroundColor: theme.palette.primary.light, '&.Mui-focusVisible': { backgroundColor: theme.palette.primary.main } }, '& .MuiTypography-root': { fontWeight: 500, color: `${theme.palette.common.white} !important` }, '& .MuiListItemIcon-root': { color: `${theme.palette.common.white} !important` } } })) const MenuItemTextMetaWrapper = styled(Box)(({ theme }) => ({ width: '100%', display: 'flex', alignItems: 'center', gap: theme.spacing(2), justifyContent: 'space-between', transition: 'opacity .25s ease-in-out', ...(themeConfig.menuTextTruncate && { overflow: 'hidden' }) })) const VerticalNavLink = ({ item, parent, navHover, settings, navVisible, isSubToSub, collapsedNavWidth, toggleNavVisibility, navigationBorderWidth }: Props) => { // ** Hooks const router = useRouter() // ** Vars const { navCollapsed } = settings const icon = parent && !item.icon ? themeConfig.navSubItemIcon : item.icon const isNavLinkActive = () => { if (router.pathname === item.path || handleURLQueries(router, item.path) || item.includePath?.includes(router.pathname)) { return true } else { return false } } return ( (parent ? '0 !important' : `${theme.spacing(navCollapsed && !navHover ? 2 : 3)} !important`) }} > { if (item.path === undefined) { e.preventDefault() e.stopPropagation() } if (navVisible) { toggleNavVisibility() } }} sx={{ py: 2.25, ...(item.disabled ? { pointerEvents: 'none' } : { cursor: 'pointer' }), pr: navCollapsed && !navHover ? (collapsedNavWidth - navigationBorderWidth - 24 - 16) / 8 : 3, pl: navCollapsed && !navHover ? (collapsedNavWidth - navigationBorderWidth - 24 - 16) / 8 : 4 }} > {isSubToSub ? null : ( )} {item.badgeContent ? ( ) : null} ) } export default VerticalNavLink