52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
import { ReportListParams, DashboardOverviewParams } from 'models';
|
|
import {
|
|
getOverViewReport,
|
|
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,
|
|
});
|
|
}
|
|
|
|
export function useOverViewReport(params?: DashboardOverviewParams, options?: any) {
|
|
return useQuery({
|
|
queryKey: ['overview-report', params],
|
|
queryFn: () => getOverViewReport(params),
|
|
...options,
|
|
});
|
|
}
|