2023-08-24 13:10:47 +00:00
|
|
|
|
import { Box, Button, Dialog, IconButton, Typography } from "@mui/material";
|
2023-09-08 07:51:24 +00:00
|
|
|
|
import { enqueueSnackbar } from "notistack";
|
2023-06-02 08:22:14 +00:00
|
|
|
|
import CloseSmallIcon from "@root/components/icons/CloseSmallIcon";
|
2023-09-08 07:51:24 +00:00
|
|
|
|
import {
|
|
|
|
|
closeDocumentsDialog,
|
|
|
|
|
setDocument,
|
|
|
|
|
useUserStore,
|
|
|
|
|
} from "@root/stores/user";
|
2023-06-02 08:22:14 +00:00
|
|
|
|
import DocumentUploadItem from "./DocumentUploadItem";
|
|
|
|
|
import DocumentItem from "./DocumentItem";
|
2023-07-06 21:52:07 +00:00
|
|
|
|
import { verify } from "../helper";
|
2023-07-25 22:31:04 +00:00
|
|
|
|
import { VerificationStatus } from "@root/model/account";
|
2023-09-15 12:28:46 +00:00
|
|
|
|
import { sendDocuments, updateDocuments } from "@root/api/verification";
|
2023-07-13 13:30:47 +00:00
|
|
|
|
import { readFile } from "@root/utils/readFile";
|
2023-09-15 12:28:46 +00:00
|
|
|
|
import { deleteEmptyKeys } from "@root/utils/deleteEmptyKeys";
|
2023-06-02 08:22:14 +00:00
|
|
|
|
|
2023-09-11 13:45:14 +00:00
|
|
|
|
const dialogContainerStyle = {
|
|
|
|
|
height: "100%",
|
|
|
|
|
overflowY: "scroll",
|
|
|
|
|
"::-webkit-scrollbar": {
|
|
|
|
|
display: "none",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-02 08:22:14 +00:00
|
|
|
|
export default function NkoDocumentsDialog() {
|
2023-09-04 20:01:24 +00:00
|
|
|
|
const isOpen = useUserStore((state) => state.isDocumentsDialogOpen);
|
|
|
|
|
const verificationStatus = useUserStore((state) => state.verificationStatus);
|
|
|
|
|
const documents = useUserStore((state) => state.documents);
|
|
|
|
|
const documentsUrl = useUserStore((state) => state.documentsUrl);
|
|
|
|
|
const userId = useUserStore((state) => state.userId) ?? "";
|
2023-06-02 08:22:14 +00:00
|
|
|
|
|
2023-09-04 20:01:24 +00:00
|
|
|
|
const sendUploadedDocuments = async () => {
|
2023-09-08 07:51:24 +00:00
|
|
|
|
if (
|
2023-09-15 12:28:46 +00:00
|
|
|
|
documents["ИНН"].file &&
|
|
|
|
|
documents["Устав"].file &&
|
|
|
|
|
documents["Свидетельство о регистрации НКО"].file
|
|
|
|
|
) {
|
|
|
|
|
const inn = await readFile(documents["ИНН"].file, "binary");
|
|
|
|
|
const rule = await readFile(documents["Устав"].file, "binary");
|
|
|
|
|
const certificate = await readFile(
|
|
|
|
|
documents["Свидетельство о регистрации НКО"].file,
|
|
|
|
|
"binary"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const [_, sendDocumentsError] = await sendDocuments({
|
|
|
|
|
status: "nko",
|
|
|
|
|
inn,
|
|
|
|
|
rule,
|
|
|
|
|
certificate,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (sendDocumentsError) {
|
|
|
|
|
enqueueSnackbar(sendDocumentsError);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const inn = documents["ИНН"].file
|
|
|
|
|
? await readFile(documents["ИНН"].file, "binary")
|
|
|
|
|
: undefined;
|
|
|
|
|
const rule = documents["Устав"].file
|
|
|
|
|
? await readFile(documents["Устав"].file, "binary")
|
|
|
|
|
: undefined;
|
|
|
|
|
const certificate = documents["Свидетельство о регистрации НКО"].file
|
|
|
|
|
? await readFile(
|
|
|
|
|
documents["Свидетельство о регистрации НКО"].file,
|
|
|
|
|
"binary"
|
|
|
|
|
)
|
|
|
|
|
: undefined;
|
|
|
|
|
|
|
|
|
|
const [_, updateDocumentsError] = await updateDocuments(
|
|
|
|
|
deleteEmptyKeys({
|
|
|
|
|
status: "org",
|
|
|
|
|
inn,
|
|
|
|
|
rule,
|
|
|
|
|
certificate,
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (updateDocumentsError) {
|
|
|
|
|
enqueueSnackbar(updateDocumentsError);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-09-08 07:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeDocumentsDialog();
|
2023-07-06 21:52:07 +00:00
|
|
|
|
|
2023-09-04 20:01:24 +00:00
|
|
|
|
setDocument("ИНН", null);
|
|
|
|
|
setDocument("Устав", null);
|
|
|
|
|
setDocument("Свидетельство о регистрации НКО", null);
|
2023-07-06 21:52:07 +00:00
|
|
|
|
|
2023-09-04 20:01:24 +00:00
|
|
|
|
await verify(userId);
|
|
|
|
|
};
|
2023-07-06 21:52:07 +00:00
|
|
|
|
|
2023-09-04 20:01:24 +00:00
|
|
|
|
const documentElements =
|
|
|
|
|
verificationStatus === VerificationStatus.VERIFICATED ? (
|
|
|
|
|
<>
|
|
|
|
|
<DocumentItem
|
|
|
|
|
text="1. Свидетельство о регистрации НКО"
|
|
|
|
|
documentUrl={documentsUrl["Свидетельство о регистрации НКО"]}
|
|
|
|
|
/>
|
2023-09-08 07:51:24 +00:00
|
|
|
|
<DocumentItem
|
|
|
|
|
text="2. Скан ИНН организации НКО (выписка из ЕГЮРЛ)"
|
|
|
|
|
documentUrl={documentsUrl["ИНН"]}
|
|
|
|
|
/>
|
|
|
|
|
<DocumentItem
|
|
|
|
|
text="3. Устав организации"
|
|
|
|
|
documentUrl={documentsUrl["Устав"]}
|
|
|
|
|
/>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<DocumentUploadItem
|
|
|
|
|
text="1. Свидетельство о регистрации НКО"
|
|
|
|
|
accept="application/pdf"
|
|
|
|
|
document={documents["Свидетельство о регистрации НКО"]}
|
|
|
|
|
documentUrl={documentsUrl["Свидетельство о регистрации НКО"]}
|
2023-09-08 07:51:24 +00:00
|
|
|
|
onFileChange={(e) =>
|
|
|
|
|
setDocument(
|
|
|
|
|
"Свидетельство о регистрации НКО",
|
|
|
|
|
e.target?.files?.[0] || null
|
|
|
|
|
)
|
|
|
|
|
}
|
2023-09-04 20:01:24 +00:00
|
|
|
|
/>
|
|
|
|
|
<DocumentUploadItem
|
|
|
|
|
text="2. Скан ИНН организации НКО (выписка из ЕГЮРЛ)"
|
|
|
|
|
accept="application/pdf"
|
|
|
|
|
document={documents["ИНН"]}
|
|
|
|
|
documentUrl={documentsUrl["ИНН"]}
|
|
|
|
|
onFileChange={(e) => setDocument("ИНН", e.target?.files?.[0] || null)}
|
|
|
|
|
/>
|
|
|
|
|
<DocumentUploadItem
|
|
|
|
|
text="3. Устав организации"
|
|
|
|
|
accept="application/pdf"
|
|
|
|
|
document={documents["Устав"]}
|
|
|
|
|
documentUrl={documentsUrl["Устав"]}
|
2023-09-08 07:51:24 +00:00
|
|
|
|
onFileChange={(e) =>
|
|
|
|
|
setDocument("Устав", e.target?.files?.[0] || null)
|
|
|
|
|
}
|
2023-09-04 20:01:24 +00:00
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-06-02 08:22:14 +00:00
|
|
|
|
|
2023-09-04 20:01:24 +00:00
|
|
|
|
return (
|
|
|
|
|
<Dialog
|
|
|
|
|
open={isOpen}
|
|
|
|
|
onClose={closeDocumentsDialog}
|
|
|
|
|
PaperProps={{
|
|
|
|
|
sx: {
|
|
|
|
|
width: "600px",
|
|
|
|
|
maxWidth: "600px",
|
|
|
|
|
backgroundColor: "white",
|
|
|
|
|
position: "relative",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
boxShadow: "none",
|
2023-09-08 07:51:24 +00:00
|
|
|
|
overflowY: "hidden",
|
2023-09-04 20:01:24 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
slotProps={{
|
|
|
|
|
backdrop: { style: { backgroundColor: "rgb(0 0 0 / 0.7)" } },
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<IconButton
|
|
|
|
|
onClick={closeDocumentsDialog}
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
right: "7px",
|
|
|
|
|
top: "7px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CloseSmallIcon />
|
|
|
|
|
</IconButton>
|
2023-09-08 07:51:24 +00:00
|
|
|
|
<Box sx={{ p: "40px", overflowY: "scroll" }}>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
<Typography variant="h5" lineHeight="100%">
|
2023-09-08 07:51:24 +00:00
|
|
|
|
{verificationStatus === VerificationStatus.VERIFICATED
|
|
|
|
|
? "Ваши документы"
|
|
|
|
|
: "Загрузите документы"}
|
2023-09-04 20:01:24 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "100%",
|
|
|
|
|
mt: "12px",
|
|
|
|
|
}}
|
2023-07-06 21:52:07 +00:00
|
|
|
|
>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
для верификации НКО в формате PDF
|
|
|
|
|
</Typography>
|
2023-09-11 13:45:14 +00:00
|
|
|
|
<Box sx={dialogContainerStyle}>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
maxHeight: "280px",
|
|
|
|
|
mt: "30px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "25px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{documentElements}
|
|
|
|
|
</Box>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
{verificationStatus === VerificationStatus.NOT_VERIFICATED && (
|
2023-09-08 07:51:24 +00:00
|
|
|
|
<Button
|
|
|
|
|
sx={{ position: "absolute", bottom: "20px", right: "20px" }}
|
|
|
|
|
onClick={sendUploadedDocuments}
|
|
|
|
|
variant="pena-contained-dark"
|
|
|
|
|
>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
Отправить
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2023-09-11 13:45:14 +00:00
|
|
|
|
<></>
|
2023-09-04 20:01:24 +00:00
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
2023-07-06 21:52:07 +00:00
|
|
|
|
}
|