mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-04 23:18:01 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
27 lines
833 B
TypeScript
27 lines
833 B
TypeScript
import axios from 'axios';
|
|
import { OntimeReport } from 'ontime-types';
|
|
|
|
import { ontimeQueryClient } from '../../common/queryClient';
|
|
import { REPORT, apiEntryUrl } from './constants';
|
|
import type { RequestOptions } from './requestOptions';
|
|
|
|
export const reportUrl = `${apiEntryUrl}/report`;
|
|
|
|
/**
|
|
* HTTP request to fetch all reports
|
|
*/
|
|
export async function fetchReport(options?: RequestOptions): Promise<OntimeReport> {
|
|
const res = await axios.get(reportUrl, { signal: options?.signal });
|
|
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 });
|
|
}
|