adminFront/src/pages/dashboard/ModalUser/index.tsx

180 lines
5.9 KiB
TypeScript
Raw Normal View History

2023-07-27 12:49:47 +00:00
import { useState } from "react";
import { useLinkClickHandler } from "react-router-dom";
2023-07-25 07:47:20 +00:00
import {
Box,
Modal,
Fade,
Backdrop,
Typography,
Tabs,
Tab,
2023-07-26 08:12:51 +00:00
useTheme,
useMediaQuery,
2023-07-25 07:47:20 +00:00
} from "@mui/material";
2022-09-12 13:28:56 +00:00
2023-07-25 07:47:20 +00:00
import { UserTab } from "./UserTab";
import { PurchaseTab } from "./PurchaseTab";
2023-07-25 14:09:07 +00:00
import { TransactionsTab } from "./TransactionsTab";
2023-07-26 06:44:13 +00:00
import { VerificationTab } from "./VerificationTab";
2022-09-22 12:09:10 +00:00
2023-07-25 07:47:20 +00:00
import userIcon from "@root/assets/icons/user.svg";
import packageIcon from "@root/assets/icons/package.svg";
import transactionsIcon from "@root/assets/icons/transactions.svg";
import checkIcon from "@root/assets/icons/check.svg";
2023-07-26 09:59:40 +00:00
import forwardIcon from "@root/assets/icons/forward.svg";
2023-07-25 07:47:20 +00:00
import type { SyntheticEvent } from "react";
2022-09-22 12:09:10 +00:00
2023-07-25 07:47:20 +00:00
const TABS = [
{ name: "Пользователь", icon: userIcon },
{ name: "Покупка товаров и услуг", icon: packageIcon },
{ name: "Транзакции", icon: transactionsIcon },
{ name: "Верификация", icon: checkIcon },
2022-09-22 12:09:10 +00:00
];
2023-07-25 07:47:20 +00:00
const ModalUser = () => {
const [value, setValue] = useState<number>(0);
2023-07-26 09:59:40 +00:00
const [openNavigation, setOpenNavigation] = useState<boolean>(false);
2023-07-26 08:12:51 +00:00
const theme = useTheme();
const tablet = useMediaQuery(theme.breakpoints.down(1070));
const mobile = useMediaQuery(theme.breakpoints.down(700));
2023-07-25 07:47:20 +00:00
2022-09-12 13:28:56 +00:00
return (
2023-07-25 07:47:20 +00:00
<>
2022-09-14 10:24:02 +00:00
<Modal
aria-labelledby="transition-modal-title"
aria-describedby="transition-modal-description"
2023-07-25 07:47:20 +00:00
open
onClose={useLinkClickHandler("/users")}
2022-09-14 10:24:02 +00:00
closeAfterTransition
BackdropComponent={Backdrop}
BackdropProps={{
timeout: 500,
}}
>
2023-07-25 07:47:20 +00:00
<Fade in>
<Box
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
display: "flex",
flexDirection: "column",
2023-07-26 09:59:40 +00:00
width: mobile ? "100%" : "98vw",
2023-07-26 08:12:51 +00:00
maxWidth: tablet ? "920px" : "1070px",
2023-07-26 09:59:40 +00:00
height: mobile ? "100%" : "605px",
2023-07-25 07:47:20 +00:00
bgcolor: theme.palette.background.default,
color: theme.palette.secondary.main,
boxShadow: 24,
2023-07-26 09:59:40 +00:00
borderRadius: mobile ? "0" : "12px",
2023-07-25 07:47:20 +00:00
outline: "none",
2023-07-27 12:49:47 +00:00
overflowX: "hidden",
2023-07-25 07:47:20 +00:00
}}
>
<Typography
id="transition-modal-title"
variant="caption"
sx={{
display: "block",
textAlign: "center",
fontSize: "18px",
padding: "12px",
2023-07-25 14:09:07 +00:00
color: theme.palette.common.white,
2023-07-25 07:47:20 +00:00
background: "#9A9AAF",
}}
>
Пользователь сервиса
2022-09-14 10:24:02 +00:00
</Typography>
2023-07-25 07:47:20 +00:00
<Box sx={{ width: "100%", height: "100%", display: "flex" }}>
2023-07-26 09:59:40 +00:00
<Box
sx={{
width: "100%",
height: "100%",
maxWidth: mobile
? openNavigation
? "276px"
: "68px"
: "276px",
}}
2022-09-21 13:47:45 +00:00
>
2023-07-26 09:59:40 +00:00
{mobile && (
<img
src={forwardIcon}
alt="forward"
style={{
display: "block",
width: "11px",
margin: "25px 0 15px 28px",
transform: openNavigation ? "rotate(180deg)" : "",
transition: ".2s",
2022-09-22 12:09:10 +00:00
}}
2023-07-26 09:59:40 +00:00
onClick={() => setOpenNavigation((isOpened) => !isOpened)}
2022-09-22 12:09:10 +00:00
/>
2023-07-26 09:59:40 +00:00
)}
<Tabs
orientation="vertical"
variant="scrollable"
value={value}
onChange={(event: SyntheticEvent, newValue: number) =>
setValue(newValue)
}
aria-label="Vertical tabs example"
sx={{
padding: mobile ? "16px" : "10px",
width: "100%",
}}
TabIndicatorProps={{ style: { background: "transparent" } }}
>
{TABS.map(({ name, icon }) => (
<Tab
icon={<img src={icon} alt={name} />}
iconPosition="start"
key={name}
label={mobile ? (openNavigation ? name : "") : name}
sx={{
justifyContent: "flex-start",
textTransform: "inherit",
minHeight: "auto",
minWidth: "auto",
fontSize: "15px",
padding: mobile ? "9px" : "15px",
marginBottom: mobile ? "15px" : "5px",
color: theme.palette.common.black,
whiteSpace: "nowrap",
lineHeight: "18px",
"&.MuiButtonBase-root.Mui-selected": {
borderRadius: "12px",
color: "#7E2AEA",
background: "rgba(126, 42, 234, 0.07)",
},
}}
/>
))}
</Tabs>
</Box>
2022-09-21 13:47:45 +00:00
2023-07-25 07:47:20 +00:00
<Box
sx={{
2023-07-26 08:12:51 +00:00
position: "relative",
2023-07-25 07:47:20 +00:00
width: "100%",
color: theme.palette.common.black,
2023-07-25 13:07:06 +00:00
boxShadow: "inset 30px 0px 40px 0px rgba(210, 208, 225, 0.2)",
2023-07-25 07:47:20 +00:00
}}
>
2023-07-27 12:49:47 +00:00
{value === 0 && <UserTab />}
2023-07-25 07:47:20 +00:00
{value === 1 && <PurchaseTab />}
2023-07-25 14:09:07 +00:00
{value === 2 && <TransactionsTab />}
2023-07-27 12:49:47 +00:00
{value === 3 && <VerificationTab />}
2023-07-25 07:47:20 +00:00
</Box>
2022-09-12 13:28:56 +00:00
</Box>
</Box>
2022-09-14 10:24:02 +00:00
</Fade>
</Modal>
2023-07-25 07:47:20 +00:00
</>
2022-09-12 13:28:56 +00:00
);
2023-07-25 07:47:20 +00:00
};
2022-09-13 16:16:57 +00:00
export default ModalUser;