mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 10:23:54 +00:00
27 lines
725 B
TypeScript
27 lines
725 B
TypeScript
import axios from 'axios';
|
|
import { OntimeReport } from 'ontime-types';
|
|
|
|
import { ontimeQueryClient } from '../../common/queryClient';
|
|
|
|
import { apiEntryUrl, REPORT } from './constants';
|
|
|
|
export const reportUrl = `${apiEntryUrl}/report`;
|
|
|
|
/**
|
|
* HTTP request to fetch all reports
|
|
*/
|
|
export async function fetchReport(): Promise<OntimeReport> {
|
|
const res = await axios.get(reportUrl);
|
|
return res.data;
|
|
}
|
|
|
|
export async function deleteReport(id: string) {
|
|
await axios.delete(`${reportUrl}/${id}`);
|
|
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
|
}
|
|
|
|
export async function deleteAllReport() {
|
|
await axios.delete(`${reportUrl}/all`);
|
|
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
|
}
|