sbt-idp/cope2n-fe/src/queries/report.ts

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-01-31 04:08:20 +00:00
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { ReportListParams } from 'models';
import { getReportDetailList, getReportList, makeReport } from 'request/report';
import {
CustomUseMutationOptions,
MakeReportParams,
ReportDetailListParams,
} from './../models/report';
export function useReportDetailList(
params?: ReportDetailListParams,
options?: any,
) {
return useQuery({
queryKey: ['report-detail', params],
queryFn: () => getReportDetailList(params),
...options,
});
}
export function useMakeReport(options?: CustomUseMutationOptions) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (params: MakeReportParams) => makeReport(params),
...options,
onSuccess() {
queryClient.invalidateQueries(['report-list']);
},
});
}
export function useReportList(params?: ReportListParams, options?: any) {
return useQuery({
queryKey: ['report-list', params],
queryFn: () => getReportList(params),
...options,
});
}