28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
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<InternshipDocument>, comment?: string): Promise<void> {
|
|
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<InternshipDocument>, comment: string): Promise<void> {
|
|
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' } }
|
|
)))
|
|
}
|