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