import { useRouter } from 'next/router'; import { IconBox, IconBriefcase, IconCheck, IconLogout, IconShoppingBag, } from '@tabler/icons-react'; import { NavbarLink, NavbarLinkKey } from '@/components/Layout/Navbar/types'; import classes from './Navbar.module.css'; const data: NavbarLink[] = [ { href: '/products', key: 'products', label: 'Товары', icon: IconBox }, { href: '/marketplaces', key: 'marketplaces', label: 'Маркетплейсы', icon: IconShoppingBag }, { href: '/legal-entities', key: 'legal-entities', label: 'Юр. лица', icon: IconBriefcase }, { href: '/deal-requests', key: 'deal-requests', label: 'Заявки на сделку', icon: IconCheck }, ]; const hrefToKeyMap: Record = data.reduce( (acc, item) => ({ ...acc, [`${item.href}`]: `${item.key}` }), { '/': 'index' } ); export function Navbar() { const router = useRouter(); const currentPath = router.pathname; const active = hrefToKeyMap[currentPath]; const links = data.map((item) => { return ( { event.preventDefault(); await router.push(item.href); }} > {item.label} ); }); return ( ); } export default Navbar;