fix: verification useless API request

This commit is contained in:
IlyaDoronin 2023-09-06 12:02:17 +03:00
parent e289165510
commit 580b4cba29
2 changed files with 10 additions and 13 deletions

@ -15,7 +15,7 @@ export async function verification(
): Promise<[Verification | null, string?]> {
try {
const verificationResponse = await makeRequest<never, Verification>({
url: apiUrl + "/verification" + userId,
url: apiUrl + "/verification/" + userId,
method: "GET",
useToken: true,
withCredentials: true,

@ -26,8 +26,6 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
import.meta.url
).toString();
const DEFAULT_DOCUMENT_URL = "https://hub.pena.digital";
export default function DocumentUploadItem({
text,
document,
@ -43,11 +41,10 @@ export default function DocumentUploadItem({
}
const downloadFile = async () => {
if (!document.file) {
const { data } = await axios.get<ArrayBuffer>(
documentUrl || DEFAULT_DOCUMENT_URL,
{ responseType: "arraybuffer" }
);
if (!document.file && documentUrl) {
const { data } = await axios.get<ArrayBuffer>(documentUrl, {
responseType: "arraybuffer",
});
if (!data) {
return;
@ -58,9 +55,11 @@ export default function DocumentUploadItem({
return;
}
if (document.file) {
const binaryFile = await readFile(document.file, "binary");
downloadFileToDevice(binaryFile.name, Buffer.from(binaryFile.content));
}
};
return (
@ -97,9 +96,7 @@ export default function DocumentUploadItem({
multiple
accept={accept}
/>
<Document
file={document.file || { url: documentUrl || DEFAULT_DOCUMENT_URL }}
>
<Document file={document.file || (documentUrl && { url: documentUrl })}>
<Page
pageNumber={1}
width={200}