import { encapsulate, OneOrMany } from "@/helpers"; import { axios } from "@/api"; import { prepare } from "@/routing"; import { Report } from "@/data/report"; const REPORT_ACCEPT_ENDPOINT = "/management/report/:id/accept"; const REPORT_REJECT_ENDPOINT = "/management/report/:id/reject"; export async function accept(document: OneOrMany, comment?: string): Promise { const documents = encapsulate(document) await Promise.all(documents.map(document => axios.put( prepare(REPORT_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(REPORT_REJECT_ENDPOINT, { id: document.id || ""}), JSON.stringify(comment), { headers: { 'Content-Type': 'application/json' } } ))) }