2023-07-25 07:47:20 +00:00
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import { useLinkClickHandler, useParams } from "react-router-dom";
|
|
|
|
|
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 { authStore } from "@root/stores/auth";
|
|
|
|
|
import theme from "@root/theme";
|
2022-09-12 13:28:56 +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";
|
|
|
|
|
|
|
|
|
|
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 baseUrl =
|
|
|
|
|
process.env.NODE_ENV === "production" ? "" : "https://hub.pena.digital";
|
|
|
|
|
|
2023-07-26 06:44:13 +00:00
|
|
|
|
export type File = {
|
2023-07-25 07:47:20 +00:00
|
|
|
|
name: "inn" | "rule" | "egrule" | "certificate";
|
|
|
|
|
url: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Verification = {
|
|
|
|
|
_id: string;
|
|
|
|
|
accepted: boolean;
|
|
|
|
|
status: "org" | "nko";
|
|
|
|
|
updated_at: string;
|
|
|
|
|
comment: string;
|
|
|
|
|
files: File[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ModalUser = () => {
|
|
|
|
|
const [user, setUser] = useState<Verification | null>(null);
|
|
|
|
|
const [value, setValue] = useState<number>(0);
|
|
|
|
|
const { userId } = useParams();
|
|
|
|
|
const { makeRequest } = authStore();
|
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
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
makeRequest<never, Verification>({
|
|
|
|
|
method: "get",
|
|
|
|
|
url: baseUrl + `/verification/verification/${userId}`,
|
|
|
|
|
}).then(setUser);
|
|
|
|
|
}, []);
|
2022-09-21 13:47:45 +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",
|
|
|
|
|
width: "100%",
|
2023-07-26 08:12:51 +00:00
|
|
|
|
maxWidth: tablet ? "920px" : "1070px",
|
2023-07-25 07:47:20 +00:00
|
|
|
|
height: "605px",
|
|
|
|
|
bgcolor: theme.palette.background.default,
|
|
|
|
|
color: theme.palette.secondary.main,
|
|
|
|
|
boxShadow: 24,
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
outline: "none",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<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-19 16:17:03 +00:00
|
|
|
|
Пользователь сервиса
|
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" }}>
|
2022-09-21 13:47:45 +00:00
|
|
|
|
<Tabs
|
|
|
|
|
orientation="vertical"
|
|
|
|
|
variant="scrollable"
|
|
|
|
|
value={value}
|
2023-07-25 07:47:20 +00:00
|
|
|
|
onChange={(event: SyntheticEvent, newValue: number) =>
|
|
|
|
|
setValue(newValue)
|
|
|
|
|
}
|
2022-09-21 13:47:45 +00:00
|
|
|
|
aria-label="Vertical tabs example"
|
2023-07-25 07:47:20 +00:00
|
|
|
|
sx={{ padding: "10px", width: "100%", maxWidth: "276px" }}
|
|
|
|
|
TabIndicatorProps={{ style: { background: "transparent" } }}
|
2022-09-21 13:47:45 +00:00
|
|
|
|
>
|
2023-07-25 07:47:20 +00:00
|
|
|
|
{TABS.map(({ name, icon }) => (
|
|
|
|
|
<Tab
|
|
|
|
|
icon={<img src={icon} alt={name} />}
|
|
|
|
|
iconPosition="start"
|
|
|
|
|
key={name}
|
|
|
|
|
label={name}
|
2022-09-22 12:09:10 +00:00
|
|
|
|
sx={{
|
2023-07-25 07:47:20 +00:00
|
|
|
|
justifyContent: "flex-start",
|
|
|
|
|
textTransform: "inherit",
|
|
|
|
|
minHeight: "auto",
|
|
|
|
|
fontSize: "15px",
|
|
|
|
|
padding: "15px",
|
|
|
|
|
marginBottom: "5px",
|
|
|
|
|
color: theme.palette.common.black,
|
|
|
|
|
"&.MuiButtonBase-root.Mui-selected": {
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
background: "rgba(126, 42, 234, 0.07)",
|
2022-09-22 12:09:10 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-07-25 07:47:20 +00:00
|
|
|
|
))}
|
|
|
|
|
</Tabs>
|
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
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{value === 0 && (
|
|
|
|
|
<UserTab
|
|
|
|
|
user={{
|
|
|
|
|
id: 2810,
|
|
|
|
|
registrationDate: "17.02.2023",
|
|
|
|
|
email: "emailexamle@gmail.com",
|
|
|
|
|
phone: "+7 123 456 78 90",
|
|
|
|
|
type: "НКО",
|
|
|
|
|
fullname: "Куликов Геннадий Викторович",
|
|
|
|
|
walletBalance: "2 096 руб.",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{value === 1 && <PurchaseTab />}
|
2023-07-25 14:09:07 +00:00
|
|
|
|
{value === 2 && <TransactionsTab />}
|
2023-07-26 06:44:13 +00:00
|
|
|
|
{value === 3 && <VerificationTab files={user?.files || []} />}
|
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
|
|
|
|
|
2022-09-19 16:17:03 +00:00
|
|
|
|
export default ModalUser;
|