front-hub/src/api/verification.ts

30 lines
829 B
TypeScript
Raw Normal View History

2023-07-06 21:52:07 +00:00
import { makeRequest } from "@frontend/kitui";
2023-07-13 13:30:47 +00:00
import { jsonToFormdata } from "@root/utils/jsonToFormdata.util";
import type { Verification, SendDocumentsArgs } from "@root/model/auth";
2023-07-06 21:52:07 +00:00
const apiUrl =
process.env.NODE_ENV === "production" ? "" : "https://hub.pena.digital";
2023-07-13 12:11:30 +00:00
export function verification(userId: string) {
2023-07-06 21:52:07 +00:00
return makeRequest<never, Verification>({
2023-07-13 12:11:30 +00:00
url: apiUrl + "/verification/verification/" + userId,
2023-07-06 21:52:07 +00:00
method: "GET",
useToken: true,
withCredentials: true,
});
}
2023-07-13 12:11:30 +00:00
export function sendDocuments(userId: string, documents: SendDocumentsArgs) {
const formData = jsonToFormdata(documents);
return makeRequest<FormData, Verification>({
2023-07-13 12:11:30 +00:00
url: apiUrl + "/verification/verification/" + userId,
method: "POST",
useToken: true,
2023-07-13 12:11:30 +00:00
withCredentials: true,
body: formData,
});
}