260507_01_ENH: SafetyInspectionTotal, SafetyInspectionDivDetail 페이지 구현
This commit is contained in:
27
src/query/statistics.ts
Normal file
27
src/query/statistics.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {CsiDataMap, DivDetailDataMap} from "@/types/kfpa";
|
||||
import {statisticsQueryKeys} from "@/query/key/keys";
|
||||
|
||||
export const getCsiData = () => {
|
||||
return nextApi.get<CsiDataMap>("/statistics/csi");
|
||||
};
|
||||
|
||||
export const getDivDetailData = (divId: string | number) => {
|
||||
return nextApi.get<DivDetailDataMap>(`/statistics/div-detail/${divId}`);
|
||||
};
|
||||
|
||||
export const useCsiDataQuery = () => {
|
||||
return useQuery({
|
||||
queryKey: statisticsQueryKeys.csi(),
|
||||
queryFn: getCsiData,
|
||||
});
|
||||
};
|
||||
|
||||
export const useDivDetailDataQuery = (divId: string | number, enabled = true) => {
|
||||
return useQuery({
|
||||
queryKey: statisticsQueryKeys.divDetail(divId),
|
||||
queryFn: () => getDivDetailData(divId),
|
||||
enabled,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user