import { axios } from "@/api/index"; import { InternshipDocument } from "@/api/dto/internship-registration"; import { prepare } from "@/routing"; import { Identifiable } from "@/data"; export enum UploadType { Ipp = "IppScan", DeanConsent = "DeanConsent", Insurance = "NnwInsurance", } export interface DocumentFileInfo extends Identifiable { filename: string; size: number; mime: string; } const CREATE_DOCUMENT_ENDPOINT = '/document'; const DOCUMENT_UPLOAD_ENDPOINT = '/document/:id/scan'; export async function create(type: UploadType) { const response = await axios.post(CREATE_DOCUMENT_ENDPOINT, { type }); return response.data; } export async function upload(document: InternshipDocument, file: File) { const data = new FormData(); data.append('documentScan', file) const response = await axios.put(prepare(DOCUMENT_UPLOAD_ENDPOINT, { id: document.id as string }), data); return true; } export async function fileinfo(document: InternshipDocument): Promise { const response = await axios.get(prepare(DOCUMENT_UPLOAD_ENDPOINT, { id: document.id as string })); return response.data; }