39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
![]() |
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,
|
||
|
});
|
||
|
}
|