import { useEffect } from "react"; import { Box, Button, SxProps, Theme, Typography, useMediaQuery, useTheme, } from "@mui/material"; import InputTextfield from "@components/InputTextfield"; import PasswordInput from "@components/passwordInput"; import SectionWrapper from "@components/SectionWrapper"; import { openDocumentsDialog, sendUserData, setSettingsField, useUserStore, } from "@root/stores/user"; import UnderlinedButtonWithIcon from "@root/components/UnderlinedButtonWithIcon"; import UploadIcon from "@root/components/icons/UploadIcon"; import DocumentsDialog from "./DocumentsDialog/DocumentsDialog"; import EyeIcon from "@root/components/icons/EyeIcon"; import { cardShadow } from "@root/utils/theme"; import { getMessageFromFetchError } from "@frontend/kitui"; import { enqueueSnackbar } from "notistack"; import { VerificationStatus } from "@root/model/account"; import { verify } from "./helper"; export default function AccountSettings() { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const upSm = useMediaQuery(theme.breakpoints.up("sm")); const fields = useUserStore((state) => state.settingsFields); const verificationStatus = useUserStore((state) => state.verificationStatus); const verificationType = useUserStore((state) => state.verificationType); const comment = useUserStore((state) => state.comment); const userId = useUserStore((state) => state.userId) ?? ""; useEffect(() => { verify(userId); }, []); const textFieldProps = { gap: upMd ? "16px" : "10px", color: "#F2F3F7", bold: true, }; const verificationStatusData: Record< VerificationStatus, { text: string; color: string; } > = { verificated: { text: "Верификация пройдена", color: "#0D9F00" }, waiting: { text: "В ожидании верификации", color: "#F18956" }, notVerificated: { text: "Не верифицирован", color: "#E02C2C" }, }; function handleSendDataClick() { sendUserData() .then(() => { enqueueSnackbar("Информация обновлена"); }) .catch((error) => { const message = getMessageFromFetchError(error); if (message) enqueueSnackbar(message); }); } function VerificationIndicator({ verificationStatus, sx, }: { verificationStatus: VerificationStatus; sx?: SxProps; }) { return ( {verificationStatusData[verificationStatus].text} ); } return ( Настройки аккаунта setSettingsField("firstname", e.target.value)} id="firstname" label="Имя" {...textFieldProps} /> setSettingsField("secondname", e.target.value)} id="secondname" label="Фамилия" {...textFieldProps} /> setSettingsField("middlename", e.target.value)} id="middlename" label="Отчество" {...textFieldProps} /> setSettingsField("orgname", e.target.value)} id="orgname" label="Название компании" {...textFieldProps} /> setSettingsField("email", e.target.value)} id="email" label="E-mail" {...textFieldProps} /> setSettingsField("phoneNumber", e.target.value)} id="phoneNumber" label="Телефон" {...textFieldProps} /> setSettingsField("password", e.target.value)} id="password" label="Пароль" {...textFieldProps} /> Статус {verificationStatus === VerificationStatus.NOT_VERIFICATED && ( <> } sx={{ mt: "55px" }} ButtonProps={{ onClick: () => openDocumentsDialog("juridical"), }} > Загрузить документы для юр лиц } sx={{ mt: "15px" }} ButtonProps={{ onClick: () => openDocumentsDialog("nko"), }} > Загрузить документы для НКО )} {verificationStatus === VerificationStatus.VERIFICATED && ( } sx={{ mt: "55px" }} ButtonProps={{ onClick: () => openDocumentsDialog(verificationType), }} > Посмотреть свою верификацию )} {comment &&

{comment}

}
); }