2022-09-08 17:21:17 +00:00
|
|
|
|
import * as React from "react";
|
|
|
|
|
import { Box } from "@mui/material";
|
2023-04-20 15:42:18 +00:00
|
|
|
|
import PersonOutlineOutlinedIcon from "@mui/icons-material/PersonOutlineOutlined";
|
|
|
|
|
import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined";
|
|
|
|
|
import BathtubOutlinedIcon from "@mui/icons-material/BathtubOutlined";
|
|
|
|
|
import AddPhotoAlternateOutlinedIcon from "@mui/icons-material/AddPhotoAlternateOutlined";
|
|
|
|
|
import NaturePeopleOutlinedIcon from "@mui/icons-material/NaturePeopleOutlined";
|
|
|
|
|
import SettingsIcon from "@mui/icons-material/Settings";
|
|
|
|
|
import CameraIcon from "@mui/icons-material/Camera";
|
|
|
|
|
import HeadsetMicOutlinedIcon from "@mui/icons-material/HeadsetMicOutlined";
|
2022-09-20 14:35:49 +00:00
|
|
|
|
import theme from "../../../theme";
|
2023-01-07 22:58:14 +00:00
|
|
|
|
import CssBaseline from "@mui/material/CssBaseline";
|
|
|
|
|
import Toolbar from "@mui/material/Toolbar";
|
|
|
|
|
import IconButton from "@mui/material/IconButton";
|
|
|
|
|
import MenuIcon from "@mui/icons-material/Menu";
|
|
|
|
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
|
|
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
|
|
|
import Divider from "@mui/material/Divider";
|
|
|
|
|
import List from "@mui/material/List";
|
|
|
|
|
import ListItem from "@mui/material/ListItem";
|
|
|
|
|
import ListItemButton from "@mui/material/ListItemButton";
|
|
|
|
|
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
|
|
|
import ListItemText from "@mui/material/ListItemText";
|
2023-04-20 15:42:18 +00:00
|
|
|
|
import { CSSObject, styled, Theme, useTheme } from "@mui/material/styles";
|
|
|
|
|
import MuiDrawer from "@mui/material/Drawer";
|
|
|
|
|
import MuiAppBar, { AppBarProps as MuiAppBarProps } from "@mui/material/AppBar";
|
2023-01-07 22:58:14 +00:00
|
|
|
|
import Header from "../Header/index";
|
2023-04-20 15:42:18 +00:00
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
2023-01-10 02:27:03 +00:00
|
|
|
|
import Paper from "@mui/material/Paper";
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
|
|
|
|
const drawerWidth = 240;
|
|
|
|
|
|
|
|
|
|
const openedMixin = (theme: Theme): CSSObject => ({
|
|
|
|
|
width: drawerWidth,
|
2023-04-20 15:42:18 +00:00
|
|
|
|
background: "#2f3339",
|
|
|
|
|
transition: theme.transitions.create("width", {
|
2023-01-07 22:58:14 +00:00
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
|
duration: theme.transitions.duration.enteringScreen,
|
|
|
|
|
}),
|
2023-04-20 15:42:18 +00:00
|
|
|
|
overflowX: "hidden",
|
2023-01-07 22:58:14 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const closedMixin = (theme: Theme): CSSObject => ({
|
2023-04-20 15:42:18 +00:00
|
|
|
|
transition: theme.transitions.create("width", {
|
2023-01-07 22:58:14 +00:00
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
|
duration: theme.transitions.duration.leavingScreen,
|
|
|
|
|
}),
|
2023-04-20 15:42:18 +00:00
|
|
|
|
overflowX: "hidden",
|
2023-01-07 22:58:14 +00:00
|
|
|
|
width: `calc(${theme.spacing(7)} + 1px)`,
|
2023-04-20 15:42:18 +00:00
|
|
|
|
background: "#2f3339",
|
|
|
|
|
// marginTop: '20px',
|
|
|
|
|
[theme.breakpoints.up("sm")]: {
|
2023-01-07 22:58:14 +00:00
|
|
|
|
width: `calc(${theme.spacing(8)} + 1px)`,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "flex-end",
|
2023-01-07 22:58:14 +00:00
|
|
|
|
padding: theme.spacing(0, 1),
|
|
|
|
|
...theme.mixins.toolbar,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
interface AppBarProps extends MuiAppBarProps {
|
|
|
|
|
open?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const AppBar = styled(MuiAppBar, {
|
2023-04-20 15:42:18 +00:00
|
|
|
|
shouldForwardProp: (prop) => prop !== "open",
|
2023-01-07 22:58:14 +00:00
|
|
|
|
})<AppBarProps>(({ theme, open }) => ({
|
|
|
|
|
zIndex: theme.zIndex.drawer + 1,
|
2023-04-20 15:42:18 +00:00
|
|
|
|
transition: theme.transitions.create(["width", "margin"], {
|
2023-01-07 22:58:14 +00:00
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
|
duration: theme.transitions.duration.leavingScreen,
|
|
|
|
|
}),
|
|
|
|
|
...(open && {
|
|
|
|
|
marginLeft: drawerWidth,
|
|
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
2023-04-20 15:42:18 +00:00
|
|
|
|
transition: theme.transitions.create(["width", "margin"], {
|
2023-01-07 22:58:14 +00:00
|
|
|
|
easing: theme.transitions.easing.sharp,
|
|
|
|
|
duration: theme.transitions.duration.enteringScreen,
|
|
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
}));
|
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({
|
|
|
|
|
width: drawerWidth,
|
|
|
|
|
flexShrink: 0,
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
...(open && {
|
|
|
|
|
...openedMixin(theme),
|
|
|
|
|
"& .MuiDrawer-paper": openedMixin(theme),
|
|
|
|
|
}),
|
|
|
|
|
...(!open && {
|
|
|
|
|
...closedMixin(theme),
|
|
|
|
|
"& .MuiDrawer-paper": closedMixin(theme),
|
|
|
|
|
}),
|
|
|
|
|
}));
|
2023-01-10 02:27:03 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const links: { path: string; element: JSX.Element; title: string; className: string }[] = [
|
|
|
|
|
{ path: "/users", element: <PersonOutlineOutlinedIcon />, title: "Информация о проекте", className: "menu" },
|
|
|
|
|
{ path: "/entities", element: <SettingsOutlinedIcon />, title: "Юридические лица", className: "menu" },
|
2023-05-18 20:27:46 +00:00
|
|
|
|
{ path: "/tariffs", element: <BathtubOutlinedIcon />, title: "Тарифы", className: "menu" },
|
2023-04-20 15:42:18 +00:00
|
|
|
|
{ path: "/discounts", element: <AddPhotoAlternateOutlinedIcon />, title: "Скидки", className: "menu" },
|
|
|
|
|
{ path: "/promocode", element: <NaturePeopleOutlinedIcon />, title: "Промокод", className: "menu" },
|
|
|
|
|
{ path: "/settingRoles", element: <SettingsIcon />, title: "Настройки", className: "menu" },
|
|
|
|
|
{ path: "/jjj", element: <CameraIcon />, title: "Камера", className: "menu" },
|
|
|
|
|
{ path: "/support", element: <HeadsetMicOutlinedIcon />, title: "Служба поддержки", className: "menu" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const Navigation = (props: any) => {
|
|
|
|
|
return (
|
|
|
|
|
<List
|
|
|
|
|
sx={{
|
|
|
|
|
background: "#2f3339",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-05-31 19:44:03 +00:00
|
|
|
|
{links.map((e, index) => (
|
|
|
|
|
<ListItem key={index} disablePadding sx={{ display: "block" }}>
|
|
|
|
|
<Link
|
|
|
|
|
to={e.path}
|
|
|
|
|
style={{
|
|
|
|
|
textDecoration: "none",
|
|
|
|
|
}}
|
|
|
|
|
className={e.className}
|
|
|
|
|
>
|
2023-04-20 15:42:18 +00:00
|
|
|
|
<ListItemButton
|
2023-05-31 19:44:03 +00:00
|
|
|
|
disableGutters
|
|
|
|
|
disableRipple
|
2023-04-20 15:42:18 +00:00
|
|
|
|
onClick={props.SladeMobileHC}
|
|
|
|
|
sx={{
|
|
|
|
|
minHeight: 48,
|
|
|
|
|
height: "50px",
|
|
|
|
|
justifyContent: props.visible ? "initial" : "center",
|
|
|
|
|
px: 2.5,
|
|
|
|
|
margin: "20px 0",
|
2023-05-31 19:44:03 +00:00
|
|
|
|
"&:active": {
|
|
|
|
|
background: "gray",
|
|
|
|
|
},
|
2023-04-20 15:42:18 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ListItemIcon
|
|
|
|
|
sx={{
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
mr: props.visible ? 3 : "auto",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
color: "#eaba5b",
|
|
|
|
|
transform: "scale(1.2)",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{e.element}
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
<ListItemText
|
|
|
|
|
primary={e.title}
|
|
|
|
|
sx={{
|
|
|
|
|
opacity: props.visible ? 1 : 0,
|
|
|
|
|
color: "#eaba5b",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</ListItemButton>
|
|
|
|
|
</Link>
|
|
|
|
|
</ListItem>
|
|
|
|
|
))}
|
|
|
|
|
</List>
|
|
|
|
|
);
|
|
|
|
|
};
|
2023-01-10 02:27:03 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const Menu: React.FC = () => {
|
|
|
|
|
const tablet = useMediaQuery("(max-width:600px)");
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const mobile = useMediaQuery("(max-width:340px)");
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const [open, setOpen] = React.useState(tablet ? false : true);
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const handleDrawerOpen = () => {
|
|
|
|
|
if (!mobile) {
|
|
|
|
|
setOpen(true);
|
|
|
|
|
} else {
|
|
|
|
|
SladeMobileHC();
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const handleDrawerClose = () => {
|
|
|
|
|
setOpen(false);
|
|
|
|
|
};
|
2023-01-07 22:58:14 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
const [sladeMobile, setSladeMobile] = React.useState(false);
|
|
|
|
|
const SladeMobileHC = () => {
|
|
|
|
|
if (mobile) {
|
|
|
|
|
setSladeMobile((old) => !old);
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-10-01 14:06:54 +00:00
|
|
|
|
|
2022-09-08 17:21:17 +00:00
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
2023-04-20 15:42:18 +00:00
|
|
|
|
<Box sx={{ display: "flex" }}>
|
2023-01-07 22:58:14 +00:00
|
|
|
|
<CssBaseline />
|
2023-04-20 15:42:18 +00:00
|
|
|
|
<AppBar open={open}>
|
2023-01-07 22:58:14 +00:00
|
|
|
|
<Toolbar
|
2023-04-20 15:42:18 +00:00
|
|
|
|
sx={{
|
|
|
|
|
background: "#2f3339",
|
|
|
|
|
borderBottom: "1px solid",
|
|
|
|
|
borderColor: "#45494c",
|
|
|
|
|
}}
|
2023-01-07 22:58:14 +00:00
|
|
|
|
>
|
|
|
|
|
<IconButton
|
2023-04-20 15:42:18 +00:00
|
|
|
|
aria-label="open drawer"
|
|
|
|
|
onClick={handleDrawerOpen}
|
|
|
|
|
edge="start"
|
|
|
|
|
sx={{
|
|
|
|
|
marginRight: 5,
|
|
|
|
|
...(open && { display: "none" }),
|
|
|
|
|
color: "#eaba5b",
|
|
|
|
|
background: "#2f3339",
|
|
|
|
|
}}
|
2023-01-07 22:58:14 +00:00
|
|
|
|
>
|
|
|
|
|
<MenuIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
<Header />
|
|
|
|
|
</Toolbar>
|
|
|
|
|
</AppBar>
|
2023-04-20 15:42:18 +00:00
|
|
|
|
{!mobile ? (
|
|
|
|
|
<Drawer variant="permanent" open={open}>
|
|
|
|
|
<DrawerHeader style={{ minHeight: "86px" }}>
|
|
|
|
|
<IconButton onClick={handleDrawerClose} sx={{ color: "#eaba5b" }}>
|
|
|
|
|
<ChevronLeftIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</DrawerHeader>
|
|
|
|
|
<Divider />
|
|
|
|
|
<Navigation visible={open} />
|
|
|
|
|
</Drawer>
|
|
|
|
|
) : null}
|
2022-09-08 17:21:17 +00:00
|
|
|
|
</Box>
|
2023-04-20 15:42:18 +00:00
|
|
|
|
{sladeMobile ? (
|
|
|
|
|
<Paper
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
width: "100%",
|
|
|
|
|
background: "#2f3339",
|
|
|
|
|
zIndex: theme.zIndex.drawer + 3,
|
|
|
|
|
}}
|
2023-01-10 02:27:03 +00:00
|
|
|
|
>
|
2023-04-20 15:42:18 +00:00
|
|
|
|
<Box sx={{ display: "flex", justifyContent: "end", padding: "10px" }}>
|
|
|
|
|
<IconButton onClick={SladeMobileHC} sx={{ color: "#eaba5b" }}>
|
|
|
|
|
<ChevronLeftIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
<Divider />
|
|
|
|
|
<Navigation visible={true} SladeMobileHC={SladeMobileHC} />
|
|
|
|
|
</Paper>
|
|
|
|
|
) : null}
|
2022-09-08 17:21:17 +00:00
|
|
|
|
</React.Fragment>
|
|
|
|
|
);
|
2023-04-20 15:42:18 +00:00
|
|
|
|
};
|
2022-09-08 17:21:17 +00:00
|
|
|
|
|
2023-04-20 15:42:18 +00:00
|
|
|
|
export default Menu;
|