2023-08-08 11:44:53 +00:00
|
|
|
|
import { useState, useEffect } from "react";
|
2023-07-26 10:49:08 +00:00
|
|
|
|
import { Box, Typography, useTheme, useMediaQuery } from "@mui/material";
|
2023-08-08 11:44:53 +00:00
|
|
|
|
|
|
|
|
|
import { getUserInfo } from "@root/api/user";
|
|
|
|
|
import { getAccountInfo } from "@root/api/account";
|
|
|
|
|
|
|
|
|
|
import type { UserType } from "@root/api/roles";
|
|
|
|
|
import type { Account } from "@root/api/account";
|
2023-07-25 07:47:20 +00:00
|
|
|
|
|
2023-08-14 11:58:12 +00:00
|
|
|
|
type UserTabProps = {
|
|
|
|
|
userId: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const UserTab = ({ userId }: UserTabProps) => {
|
2023-08-08 11:44:53 +00:00
|
|
|
|
const [user, setUser] = useState<UserType | null>(null);
|
|
|
|
|
const [account, setAccount] = useState<Account | null>(null);
|
2023-07-26 10:49:08 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const mobile = useMediaQuery(theme.breakpoints.down(700));
|
|
|
|
|
|
2023-08-08 11:44:53 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (userId) {
|
|
|
|
|
getUserInfo(userId).then(setUser);
|
2023-08-31 12:46:34 +00:00
|
|
|
|
getAccountInfo(userId).then(([accountsInfo]) => setAccount(accountsInfo));
|
2023-08-08 11:44:53 +00:00
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
2023-07-26 10:49:08 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: mobile ? "block" : "flex",
|
|
|
|
|
columnGap: "15px",
|
|
|
|
|
padding: "25px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ maxWidth: "300px", width: "100%" }}>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>ID</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-08 11:44:53 +00:00
|
|
|
|
{user?._id}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>Дата регистрации</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-08 11:44:53 +00:00
|
|
|
|
{new Date(user?.createdAt || "").toLocaleDateString()}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>Email</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-08 11:44:53 +00:00
|
|
|
|
{user?.email}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>Телефон</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-08 11:44:53 +00:00
|
|
|
|
{user?.phoneNumber}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>Тип:</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-09 06:58:43 +00:00
|
|
|
|
{account?.status === "no" && "Физ. лицо"}
|
|
|
|
|
{account?.status === "org" && "Юр. лицо"}
|
|
|
|
|
{account?.status === "nko" && "НКО"}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2023-07-25 07:47:20 +00:00
|
|
|
|
</Box>
|
2023-07-26 10:49:08 +00:00
|
|
|
|
<Box sx={{ maxWidth: "300px", width: "100%" }}>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>ФИО:</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-08 11:44:53 +00:00
|
|
|
|
{`${account?.name.secondname || ""} ${
|
|
|
|
|
account?.name.firstname || ""
|
|
|
|
|
} ${account?.name.middlename || ""}`}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{ marginBottom: "25px" }}>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px" }}>
|
|
|
|
|
Внутренний кошелек
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography sx={{ lineHeight: "20px", fontWeight: "bold" }}>
|
2023-08-14 11:58:12 +00:00
|
|
|
|
{`${account?.wallet.money || 0} ${
|
2023-08-08 11:44:53 +00:00
|
|
|
|
account?.wallet.currency || "RUB"
|
|
|
|
|
}.`}
|
2023-07-26 10:49:08 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2023-07-25 07:47:20 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-07-26 10:49:08 +00:00
|
|
|
|
);
|
|
|
|
|
};
|