system-praktyk-front/src/management/api/report.ts
Kacper Donat 9dbdde6baa Stuff
2021-01-12 00:22:24 +01:00

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' } }
)))
}