import { encapsulate, OneOrMany } from "@/helpers"; import { axios } from "@/api"; import { prepare } from "@/routing"; import { InternshipDocument } from "@/api/dto/internship-registration"; const DOCUMENT_ACCEPT_ENDPOINT = "/management/document/:id/accept"; const DOCUMENT_REJECT_ENDPOINT = "/management/document/:id/reject"; export async function accept(document: OneOrMany, comment?: string): Promise { const documents = encapsulate(document) await Promise.all(documents.map(document => axios.put( prepare(DOCUMENT_ACCEPT_ENDPOINT, { id: document.id || ""}), JSON.stringify(comment || ""), { headers: { 'Content-Type': 'application/json' } } ))) } export async function discard(document: OneOrMany, comment: string): Promise { const documents = encapsulate(document) await Promise.all(documents.map(document => axios.put( prepare(DOCUMENT_REJECT_ENDPOINT, { id: document.id || ""}), JSON.stringify(comment), { headers: { 'Content-Type': 'application/json' } } ))) }