feat: prettier

This commit is contained in:
2024-09-27 04:47:04 +03:00
parent c5f839d9ef
commit de4fe450ab
253 changed files with 11322 additions and 10004 deletions

View File

@@ -1,20 +1,31 @@
import {Center, Flex, Image, rem, Stack, Tooltip, UnstyledButton, useMantineColorScheme} from '@mantine/core';
import {
Center,
Flex,
Image,
rem,
Stack,
Tooltip,
UnstyledButton,
useMantineColorScheme,
} from "@mantine/core";
import {
IconBarcode,
IconBox, IconBuildingWarehouse,
IconBox,
IconBuildingWarehouse,
IconCash,
IconDashboard,
IconFileBarcode,
IconHome2,
IconLogout,
IconMan,
IconMoon, IconShoppingCart,
IconMoon,
IconShoppingCart,
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";
} 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;
@@ -28,24 +39,31 @@ interface NavbarLinkProps {
}
function NavbarLink(props: NavbarLinkProps) {
const {icon: Icon, label, active, onClick} = props;
const { icon: Icon, label, active, onClick } = props;
return (
<Tooltip display={!label ? "none" : "flex"} label={label} position="right" transitionProps={{duration: 0}}>
<UnstyledButton onClick={() => onClick && onClick(props)}
className={classes.link}
data-active={active || undefined}>
<Icon style={{width: rem(20), height: rem(20)}} stroke={1.5}/>
<Tooltip
display={!label ? "none" : "flex"}
label={label}
position="right"
transitionProps={{ duration: 0 }}>
<UnstyledButton
onClick={() => onClick && onClick(props)}
className={classes.link}
data-active={active || undefined}>
<Icon
style={{ width: rem(20), height: rem(20) }}
stroke={1.5}
/>
</UnstyledButton>
</Tooltip>
);
}
const mockdata = [
{
icon: IconCash,
label: 'Сделки',
href: '/leads'
label: "Сделки",
href: "/leads",
},
// {
// icon: IconTable,
@@ -54,48 +72,50 @@ const mockdata = [
// },
{
icon: IconMan,
label: 'Клиенты',
href: '/clients'
label: "Клиенты",
href: "/clients",
},
{
icon: IconBox,
label: 'Услуги',
href: '/services'
label: "Услуги",
href: "/services",
},
{
icon: IconBarcode,
label: 'Товары',
href: '/products'
label: "Товары",
href: "/products",
},
{
icon: IconFileBarcode,
label: 'Штрихкоды',
href: '/barcode'
label: "Штрихкоды",
href: "/barcode",
},
{
icon: IconBuildingWarehouse,
label: 'Склады отгрузки',
href: '/shipping_warehouses'
label: "Склады отгрузки",
href: "/shipping_warehouses",
},
{
icon:IconShoppingCart,
label: 'Маркетплейсы',
href: '/marketplaces'
}
icon: IconShoppingCart,
label: "Маркетплейсы",
href: "/marketplaces",
},
];
export function Navbar() {
const dispatch = useAppDispatch();
const navigate = useNavigate();
const router = useRouterState();
const {colorScheme, toggleColorScheme} = useMantineColorScheme({keepTransitions: true});
const { colorScheme, toggleColorScheme } = useMantineColorScheme({
keepTransitions: true,
});
const onLogoutClick = () => {
dispatch(logout());
navigate({to: '/login'});
}
navigate({ to: "/login" });
};
const onNavlinkClick = (props: NavbarLinkProps) => {
navigate({to: props.href});
}
navigate({ to: props.href });
};
const links = mockdata.map((link, index) => (
<NavbarLink
{...link}
@@ -108,35 +128,62 @@ export function Navbar() {
return (
<nav className={classes.navbar}>
<Flex direction={"column"} gap={rem(30)}>
<Center
p={rem(5)}
>
<Flex
direction={"column"}
gap={rem(30)}>
<Center p={rem(5)}>
<Image
flex={1}
// style={{filter: "drop-shadow(0 0 30px #fff)"}}
src={colorScheme == "dark" ? "/icons/logo-light.png" : "/icons/logo.png"}
src={
colorScheme == "dark"
? "/icons/logo-light.png"
: "/icons/logo.png"
}
/>
</Center>
<div className={classes.navbarMain}>
<Stack justify="center" gap={rem(10)}>
<Stack
justify="center"
gap={rem(10)}>
{links}
</Stack>
</div>
</Flex>
<Stack w={"100%"} justify="center" gap={0}>
<NavbarLink icon={IconDashboard}
href={"/admin"}
index={-1}
label={"Панель администратора"}
onClick={() => onNavlinkClick({href: "/admin", index: -1, icon: IconDashboard})}
<Stack
w={"100%"}
justify="center"
gap={0}>
<NavbarLink
icon={IconDashboard}
href={"/admin"}
index={-1}
label={"Панель администратора"}
onClick={() =>
onNavlinkClick({
href: "/admin",
index: -1,
icon: IconDashboard,
})
}
/>
<NavbarLink
label={"Сменить тему"}
onClick={toggleColorScheme}
icon={colorScheme == "dark" ? IconSun : IconMoon}
href={"#"}
index={-1}
/>
<NavbarLink
index={-1}
href={"#"}
onClick={onLogoutClick}
icon={IconLogout}
label="Выйти"
/>
<NavbarLink label={"Сменить тему"} onClick={toggleColorScheme}
icon={colorScheme == "dark" ? IconSun : IconMoon} href={"#"} index={-1}/>
<NavbarLink index={-1} href={"#"} onClick={onLogoutClick} icon={IconLogout} label="Выйти"/>
</Stack>
</nav>
);
}
}