import {Center, Flex, Image, rem, Stack, Tooltip, UnstyledButton, useMantineColorScheme} from '@mantine/core';
import {
IconBarcode,
IconBox,
IconCash, IconDashboard,
IconFileBarcode,
IconHome2,
IconLogout,
IconMan,
IconMoon,
IconSun,
} from '@tabler/icons-react';
import classes from './Navbar.module.css';
import {useAppDispatch} from "../../redux/store.ts";
import {logout} from "../../features/authSlice.ts";
import {useNavigate, useRouterState} from "@tanstack/react-router";
interface NavbarLinkProps {
icon: typeof IconHome2;
label?: string;
active?: boolean;
href: string;
onClick?(navlink: NavbarLinkProps): void;
index: number;
}
function NavbarLink(props: NavbarLinkProps) {
const {icon: Icon, label, active, onClick} = props;
return (
onClick && onClick(props)}
className={classes.link}
data-active={active || undefined}>
);
}
const mockdata = [
// {
// icon: IconHome2,
// label: 'Главная',
// href: '/'
// },
{
icon: IconCash,
label: 'Сделки',
href: '/leads'
},
{
icon: IconMan,
label: 'Клиенты',
href: '/clients'
},
{
icon: IconBox,
label: 'Услуги',
href: '/services'
},
{
icon: IconBarcode,
label: 'Товары',
href: '/products'
},
{
icon: IconFileBarcode,
label: 'Штрихкоды',
href: '/barcode'
}
];
export function Navbar() {
const dispatch = useAppDispatch();
const navigate = useNavigate();
const router = useRouterState();
const {colorScheme, toggleColorScheme} = useMantineColorScheme({keepTransitions: true});
const onLogoutClick = () => {
dispatch(logout());
navigate({to: '/login'});
}
const onNavlinkClick = (props: NavbarLinkProps) => {
navigate({to: props.href});
}
const links = mockdata.map((link, index) => (
));
return (
);
}