[as] refactor: 행정지원 쿼리키 관리 방식 변경
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
DesignCnstnBizCstSaveRequestDto,
|
||||
DesignCnstnBizCstSearchDto,
|
||||
@@ -35,26 +33,52 @@ import { designCnstnEsntlAtchFileService } from "./design-cnstn-esntl-atch-file-
|
||||
import { designCnstnMngService } from "./design-cnstn-mng-service";
|
||||
import { designCnstnRvwOpnnService } from "./design-cnstn-rvw-opnn-service";
|
||||
|
||||
export const designCnstnMngBaseKey = [ENDPOINT.AS_SERVICE.DESIGN_CNSTN] as const;
|
||||
export const designCnstnBizCstBaseKey = [ENDPOINT.AS_SERVICE.DESIGN_CNSTN_BIZ_CST] as const;
|
||||
export const designCnstnBizSclBaseKey = [ENDPOINT.AS_SERVICE.DESIGN_CNSTN_BIZ_SCL] as const;
|
||||
export const designCnstnEsntlAtchFileBaseKey = [
|
||||
ENDPOINT.AS_SERVICE.DESIGN_CNSTN_ESNTL_ATCH_FILE,
|
||||
] as const;
|
||||
export const designCnstnRvwOpnnBaseKey = [ENDPOINT.AS_SERVICE.DESIGN_CNSTN_RVW_OPNN] as const;
|
||||
export const designCnstnKeys = {
|
||||
all: ["design-cnstn"] as const,
|
||||
list: () => [...designCnstnKeys.all, "list"] as const,
|
||||
detail: (id: string) => [...designCnstnKeys.all, "detail", id] as const,
|
||||
};
|
||||
|
||||
export const designCnstnBizCstKeys = {
|
||||
all: ["design-cnstn-biz-cst"] as const,
|
||||
list: () => [...designCnstnBizCstKeys.all, "list"] as const,
|
||||
detail: (docNo: string, acntgSeCd: string) =>
|
||||
[...designCnstnBizCstKeys.all, "detail", docNo, acntgSeCd] as const,
|
||||
};
|
||||
|
||||
export const designCnstnBizSclKeys = {
|
||||
all: ["design-cnstn-biz-scl"] as const,
|
||||
list: () => [...designCnstnBizSclKeys.all, "list"] as const,
|
||||
detail: (docNo: string, cnstpSeCd: string) =>
|
||||
[...designCnstnBizSclKeys.all, "detail", docNo, cnstpSeCd] as const,
|
||||
};
|
||||
|
||||
export const designCnstnEsntlAtchFileKeys = {
|
||||
all: ["design-cnstn-esntl-atch-file"] as const,
|
||||
list: () => [...designCnstnEsntlAtchFileKeys.all, "list"] as const,
|
||||
detail: (docNo: string, esntlAtchFileId: string) =>
|
||||
[...designCnstnEsntlAtchFileKeys.all, "detail", docNo, esntlAtchFileId] as const,
|
||||
};
|
||||
|
||||
export const designCnstnRvwOpnnKeys = {
|
||||
all: ["design-cnstn-rvw-opnn"] as const,
|
||||
list: () => [...designCnstnRvwOpnnKeys.all, "list"] as const,
|
||||
detail: (docNo: string, rvwOpnnSn: number) =>
|
||||
[...designCnstnRvwOpnnKeys.all, "detail", docNo, rvwOpnnSn] as const,
|
||||
};
|
||||
|
||||
/* ─── DesignCnstnMng ─── */
|
||||
|
||||
export function useDesignCnstnMngPage(params: DesignCnstnMngSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnMngBaseKey, "findPage", params],
|
||||
queryKey: [...designCnstnKeys.list(), params],
|
||||
queryFn: () => designCnstnMngService.findPage(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDesignCnstnMng(id: string | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnMngBaseKey, "findById", id],
|
||||
queryKey: designCnstnKeys.detail(id!),
|
||||
queryFn: () => designCnstnMngService.findById(id!),
|
||||
enabled: Boolean(id),
|
||||
});
|
||||
@@ -65,7 +89,7 @@ export function useSaveDesignCnstnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DesignCnstnMngSaveRequestDto) => designCnstnMngService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -75,7 +99,7 @@ export function useSaveApplyDesignCnstnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DesignCnstnApplySaveRequestDto) => designCnstnMngService.saveApply(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -86,9 +110,9 @@ export function useUpdateDesignCnstnMng() {
|
||||
mutationFn: ({ id, body }: { id: string; body: DesignCnstnMngUpdateRequestDto }) =>
|
||||
designCnstnMngService.update(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...designCnstnMngBaseKey, "findById", id],
|
||||
queryKey: designCnstnKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -100,9 +124,9 @@ export function useTechReviewDesignCnstnMng() {
|
||||
mutationFn: ({ id, body }: { id: string; body: DesignCnstnApplySaveRequestDto }) =>
|
||||
designCnstnMngService.techReview(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...designCnstnMngBaseKey, "findById", id],
|
||||
queryKey: designCnstnKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -113,7 +137,7 @@ export function useDeleteDesignCnstnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => designCnstnMngService.delete(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -122,7 +146,7 @@ export function useDeleteDesignCnstnMng() {
|
||||
|
||||
export function useDesignCnstnBizCstPage(params: DesignCnstnBizCstSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnBizCstBaseKey, "findPage", params],
|
||||
queryKey: [...designCnstnBizCstKeys.list(), params],
|
||||
queryFn: () => designCnstnBizCstService.findPage(params),
|
||||
});
|
||||
}
|
||||
@@ -132,7 +156,7 @@ export function useDesignCnstnBizCst(
|
||||
acntgSeCd: string | null | undefined,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnBizCstBaseKey, "findById", designCnstnDocNo, acntgSeCd],
|
||||
queryKey: designCnstnBizCstKeys.detail(designCnstnDocNo!, acntgSeCd!),
|
||||
queryFn: () => designCnstnBizCstService.findById(designCnstnDocNo!, acntgSeCd!),
|
||||
enabled: Boolean(designCnstnDocNo && acntgSeCd),
|
||||
});
|
||||
@@ -143,8 +167,8 @@ export function useSaveDesignCnstnBizCst() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DesignCnstnBizCstSaveRequestDto) => designCnstnBizCstService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -162,11 +186,11 @@ export function useUpdateDesignCnstnBizCst() {
|
||||
body: DesignCnstnBizCstUpdateRequestDto;
|
||||
}) => designCnstnBizCstService.update(designCnstnDocNo, acntgSeCd, body),
|
||||
onSuccess: (_data, { designCnstnDocNo, acntgSeCd }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...designCnstnBizCstBaseKey, "findById", designCnstnDocNo, acntgSeCd],
|
||||
queryKey: designCnstnBizCstKeys.detail(designCnstnDocNo, acntgSeCd),
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -182,8 +206,8 @@ export function useDeleteDesignCnstnBizCst() {
|
||||
acntgSeCd: string;
|
||||
}) => designCnstnBizCstService.delete(designCnstnDocNo, acntgSeCd),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -192,7 +216,7 @@ export function useDeleteDesignCnstnBizCst() {
|
||||
|
||||
export function useDesignCnstnBizSclPage(params: DesignCnstnBizSclSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnBizSclBaseKey, "findPage", params],
|
||||
queryKey: [...designCnstnBizSclKeys.list(), params],
|
||||
queryFn: () => designCnstnBizSclService.findPage(params),
|
||||
});
|
||||
}
|
||||
@@ -202,7 +226,7 @@ export function useDesignCnstnBizScl(
|
||||
cnstpSeCd: string | null | undefined,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnBizSclBaseKey, "findById", designCnstnDocNo, cnstpSeCd],
|
||||
queryKey: designCnstnBizSclKeys.detail(designCnstnDocNo!, cnstpSeCd!),
|
||||
queryFn: () => designCnstnBizSclService.findById(designCnstnDocNo!, cnstpSeCd!),
|
||||
enabled: Boolean(designCnstnDocNo && cnstpSeCd),
|
||||
});
|
||||
@@ -213,8 +237,8 @@ export function useSaveDesignCnstnBizScl() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DesignCnstnBizSclSaveRequestDto) => designCnstnBizSclService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -232,11 +256,11 @@ export function useUpdateDesignCnstnBizScl() {
|
||||
body: DesignCnstnBizSclUpdateRequestDto;
|
||||
}) => designCnstnBizSclService.update(designCnstnDocNo, cnstpSeCd, body),
|
||||
onSuccess: (_data, { designCnstnDocNo, cnstpSeCd }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...designCnstnBizSclBaseKey, "findById", designCnstnDocNo, cnstpSeCd],
|
||||
queryKey: designCnstnBizSclKeys.detail(designCnstnDocNo, cnstpSeCd),
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -252,8 +276,8 @@ export function useDeleteDesignCnstnBizScl() {
|
||||
cnstpSeCd: string;
|
||||
}) => designCnstnBizSclService.delete(designCnstnDocNo, cnstpSeCd),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -262,7 +286,7 @@ export function useDeleteDesignCnstnBizScl() {
|
||||
|
||||
export function useDesignCnstnEsntlAtchFilePage(params: DesignCnstnEsntlAtchFileSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnEsntlAtchFileBaseKey, "findPage", params],
|
||||
queryKey: [...designCnstnEsntlAtchFileKeys.list(), params],
|
||||
queryFn: () => designCnstnEsntlAtchFileService.findPage(params),
|
||||
});
|
||||
}
|
||||
@@ -272,14 +296,8 @@ export function useDesignCnstnEsntlAtchFile(
|
||||
esntlAtchFileId: string | null | undefined,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
...designCnstnEsntlAtchFileBaseKey,
|
||||
"findById",
|
||||
designCnstnDocNo,
|
||||
esntlAtchFileId,
|
||||
],
|
||||
queryFn: () =>
|
||||
designCnstnEsntlAtchFileService.findById(designCnstnDocNo!, esntlAtchFileId!),
|
||||
queryKey: designCnstnEsntlAtchFileKeys.detail(designCnstnDocNo!, esntlAtchFileId!),
|
||||
queryFn: () => designCnstnEsntlAtchFileService.findById(designCnstnDocNo!, esntlAtchFileId!),
|
||||
enabled: Boolean(designCnstnDocNo && esntlAtchFileId),
|
||||
});
|
||||
}
|
||||
@@ -290,8 +308,8 @@ export function useSaveDesignCnstnEsntlAtchFile() {
|
||||
mutationFn: (body: DesignCnstnEsntlAtchFileSaveRequestDto) =>
|
||||
designCnstnEsntlAtchFileService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -309,16 +327,11 @@ export function useUpdateDesignCnstnEsntlAtchFile() {
|
||||
body: DesignCnstnEsntlAtchFileUpdateRequestDto;
|
||||
}) => designCnstnEsntlAtchFileService.update(designCnstnDocNo, esntlAtchFileId, body),
|
||||
onSuccess: (_data, { designCnstnDocNo, esntlAtchFileId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [
|
||||
...designCnstnEsntlAtchFileBaseKey,
|
||||
"findById",
|
||||
designCnstnDocNo,
|
||||
esntlAtchFileId,
|
||||
],
|
||||
queryKey: designCnstnEsntlAtchFileKeys.detail(designCnstnDocNo, esntlAtchFileId),
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -334,8 +347,8 @@ export function useDeleteDesignCnstnEsntlAtchFile() {
|
||||
esntlAtchFileId: string;
|
||||
}) => designCnstnEsntlAtchFileService.delete(designCnstnDocNo, esntlAtchFileId),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -344,7 +357,7 @@ export function useDeleteDesignCnstnEsntlAtchFile() {
|
||||
|
||||
export function useDesignCnstnRvwOpnnPage(params: DesignCnstnRvwOpnnSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnRvwOpnnBaseKey, "findPage", params],
|
||||
queryKey: [...designCnstnRvwOpnnKeys.list(), params],
|
||||
queryFn: () => designCnstnRvwOpnnService.findPage(params),
|
||||
});
|
||||
}
|
||||
@@ -354,7 +367,7 @@ export function useDesignCnstnRvwOpnn(
|
||||
rvwOpnnSn: number | null | undefined,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [...designCnstnRvwOpnnBaseKey, "findById", designCnstnDocNo, rvwOpnnSn],
|
||||
queryKey: designCnstnRvwOpnnKeys.detail(designCnstnDocNo!, rvwOpnnSn!),
|
||||
queryFn: () => designCnstnRvwOpnnService.findById(designCnstnDocNo!, rvwOpnnSn!),
|
||||
enabled: Boolean(designCnstnDocNo && rvwOpnnSn != null),
|
||||
});
|
||||
@@ -365,8 +378,8 @@ export function useSaveDesignCnstnRvwOpnn() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DesignCnstnRvwOpnnSaveRequestDto) => designCnstnRvwOpnnService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -384,11 +397,11 @@ export function useUpdateDesignCnstnRvwOpnn() {
|
||||
body: DesignCnstnRvwOpnnUpdateRequestDto;
|
||||
}) => designCnstnRvwOpnnService.update(designCnstnDocNo, rvwOpnnSn, body),
|
||||
onSuccess: (_data, { designCnstnDocNo, rvwOpnnSn }) => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...designCnstnRvwOpnnBaseKey, "findById", designCnstnDocNo, rvwOpnnSn],
|
||||
queryKey: designCnstnRvwOpnnKeys.detail(designCnstnDocNo, rvwOpnnSn),
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -404,8 +417,8 @@ export function useDeleteDesignCnstnRvwOpnn() {
|
||||
rvwOpnnSn: number;
|
||||
}) => designCnstnRvwOpnnService.delete(designCnstnDocNo, rvwOpnnSn),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ export { designCnstnEsntlAtchFileService } from "./api/design-cnstn-esntl-atch-f
|
||||
export { designCnstnMngService } from "./api/design-cnstn-mng-service";
|
||||
export { designCnstnRvwOpnnService } from "./api/design-cnstn-rvw-opnn-service";
|
||||
export {
|
||||
designCnstnBizCstBaseKey,
|
||||
designCnstnBizSclBaseKey,
|
||||
designCnstnEsntlAtchFileBaseKey,
|
||||
designCnstnMngBaseKey,
|
||||
designCnstnRvwOpnnBaseKey,
|
||||
designCnstnBizCstKeys,
|
||||
designCnstnBizSclKeys,
|
||||
designCnstnEsntlAtchFileKeys,
|
||||
designCnstnKeys,
|
||||
designCnstnRvwOpnnKeys,
|
||||
useDeleteDesignCnstnBizCst,
|
||||
useDeleteDesignCnstnBizScl,
|
||||
useDeleteDesignCnstnEsntlAtchFile,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
DocPrgrsUpdateRequestDto,
|
||||
FnrsCnsltnApplySaveRequestDto,
|
||||
@@ -12,18 +10,22 @@ import type {
|
||||
|
||||
import { fnrsCnsltnMngService } from "./fnrs-cnsltn-service";
|
||||
|
||||
export const fnrsCnsltnMngBaseKey = [ENDPOINT.AS_SERVICE.FNRS_CNSLTN_MNG] as const;
|
||||
export const fnrsCnsltnKeys = {
|
||||
all: ["fnrs-cnsltn"] as const,
|
||||
list: () => [...fnrsCnsltnKeys.all, "list"] as const,
|
||||
detail: (id: string) => [...fnrsCnsltnKeys.all, "detail", id] as const,
|
||||
};
|
||||
|
||||
export function useFnrsCnsltnMngPage(params: FnrsCnsltnMngSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findPage", params],
|
||||
queryKey: [...fnrsCnsltnKeys.list(), params],
|
||||
queryFn: () => fnrsCnsltnMngService.findPage(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFnrsCnsltnMng(fnrsCnsltnDocNo: string | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findById", fnrsCnsltnDocNo],
|
||||
queryKey: fnrsCnsltnKeys.detail(fnrsCnsltnDocNo!),
|
||||
queryFn: () => fnrsCnsltnMngService.findById(fnrsCnsltnDocNo!),
|
||||
enabled: Boolean(fnrsCnsltnDocNo),
|
||||
});
|
||||
@@ -34,7 +36,7 @@ export function useSaveFnrsCnsltnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (body: FnrsCnsltnMngSaveRequestDto) => fnrsCnsltnMngService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -44,7 +46,7 @@ export function useSaveApplyFnrsCnsltnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (body: FnrsCnsltnApplySaveRequestDto) => fnrsCnsltnMngService.saveApply(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -60,9 +62,9 @@ export function useUpdateFnrsCnsltnMng() {
|
||||
body: FnrsCnsltnMngUpdateRequestDto;
|
||||
}) => fnrsCnsltnMngService.update(fnrsCnsltnDocNo, body),
|
||||
onSuccess: (_data, { fnrsCnsltnDocNo }) => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findById", fnrsCnsltnDocNo],
|
||||
queryKey: fnrsCnsltnKeys.detail(fnrsCnsltnDocNo),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -74,9 +76,9 @@ export function useTechReviewFnrsCnsltnMng() {
|
||||
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
||||
fnrsCnsltnMngService.techReview(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findById", id],
|
||||
queryKey: fnrsCnsltnKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -88,9 +90,9 @@ export function useSubmitSupplementFnrsCnsltnMng() {
|
||||
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
||||
fnrsCnsltnMngService.submitSupplement(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findById", id],
|
||||
queryKey: fnrsCnsltnKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -102,9 +104,9 @@ export function useSubmitReqSupplementFnrsCnsltnMng() {
|
||||
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
||||
fnrsCnsltnMngService.submitReqSupplement(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...fnrsCnsltnMngBaseKey, "findById", id],
|
||||
queryKey: fnrsCnsltnKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -115,7 +117,7 @@ export function useDeleteFnrsCnsltnMng() {
|
||||
return useMutation({
|
||||
mutationFn: (fnrsCnsltnDocNo: string) => fnrsCnsltnMngService.remove(fnrsCnsltnDocNo),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -125,7 +127,7 @@ export function useChangePrgrsSttsComCd() {
|
||||
return useMutation({
|
||||
mutationFn: (body: DocPrgrsUpdateRequestDto) => fnrsCnsltnMngService.changePrgrsSttsComCd(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnMngBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export { fnrsCnsltnMngService } from "./api/fnrs-cnsltn-service";
|
||||
export { fnrsCnsltnMngBaseKey } from "./api/queries";
|
||||
export { fnrsCnsltnKeys } from "./api/queries";
|
||||
export {
|
||||
useChangePrgrsSttsComCd,
|
||||
useDeleteFnrsCnsltnMng,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
SewerBscPlanApplySaveRequestDto,
|
||||
SewerBscPlanSaveRequestDto,
|
||||
@@ -13,18 +11,26 @@ import type {
|
||||
|
||||
import { sewerBscPlanService } from "./sewer-bsc-plan-service";
|
||||
|
||||
export const sewerBscPlanBaseKey = [ENDPOINT.AS_SERVICE.SEWER_BSC_PLAN] as const;
|
||||
export const sewerBscPlanKeys = {
|
||||
all: ["sewer-bsc-plan"] as const,
|
||||
list: () => [...sewerBscPlanKeys.all, "list"] as const,
|
||||
detail: (id: string) => [...sewerBscPlanKeys.all, "detail", id] as const,
|
||||
details: (id: string, chgCycl?: number) =>
|
||||
chgCycl == null
|
||||
? ([...sewerBscPlanKeys.all, "details", id] as const)
|
||||
: ([...sewerBscPlanKeys.all, "details", id, chgCycl] as const),
|
||||
};
|
||||
|
||||
export function useSewerBscPlanPage(params: SewerBscPlanSearchRequestDto) {
|
||||
return useQuery({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findPage", params],
|
||||
queryKey: [...sewerBscPlanKeys.list(), params],
|
||||
queryFn: () => sewerBscPlanService.findPage(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSewerBscPlan(sewerBscPlanDocNo: string | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findById", sewerBscPlanDocNo],
|
||||
queryKey: sewerBscPlanKeys.detail(sewerBscPlanDocNo!),
|
||||
queryFn: () => sewerBscPlanService.findById(sewerBscPlanDocNo!),
|
||||
enabled: Boolean(sewerBscPlanDocNo),
|
||||
});
|
||||
@@ -35,7 +41,7 @@ export function useSewerBscPlanDetails(
|
||||
chgCycl: number | null | undefined,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findDetails", sewerBscPlanDocNo, chgCycl],
|
||||
queryKey: sewerBscPlanKeys.details(sewerBscPlanDocNo!, chgCycl ?? undefined),
|
||||
queryFn: () => sewerBscPlanService.findDetails(sewerBscPlanDocNo!, chgCycl!),
|
||||
enabled: Boolean(sewerBscPlanDocNo) && chgCycl != null,
|
||||
});
|
||||
@@ -46,7 +52,7 @@ export function useSaveSewerBscPlan() {
|
||||
return useMutation({
|
||||
mutationFn: (body: SewerBscPlanSaveRequestDto) => sewerBscPlanService.save(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -62,9 +68,9 @@ export function useUpdateSewerBscPlan() {
|
||||
body: SewerBscPlanUpdateRequestDto;
|
||||
}) => sewerBscPlanService.update(sewerBscPlanDocNo, body),
|
||||
onSuccess: (_data, { sewerBscPlanDocNo }) => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findById", sewerBscPlanDocNo],
|
||||
queryKey: sewerBscPlanKeys.detail(sewerBscPlanDocNo),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -75,7 +81,7 @@ export function useDeleteSewerBscPlan() {
|
||||
return useMutation({
|
||||
mutationFn: (sewerBscPlanDocNo: string) => sewerBscPlanService.delete(sewerBscPlanDocNo),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -85,7 +91,7 @@ export function useSaveApplySewerBscPlan() {
|
||||
return useMutation({
|
||||
mutationFn: (body: SewerBscPlanApplySaveRequestDto) => sewerBscPlanService.saveApply(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -96,9 +102,9 @@ export function useSubmitSupplementSewerBscPlan() {
|
||||
mutationFn: ({ id, body }: { id: string; body: SewerBscPlanApplySaveRequestDto }) =>
|
||||
sewerBscPlanService.submitSupplement(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findById", id],
|
||||
queryKey: sewerBscPlanKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -117,9 +123,9 @@ export function useSubmitReqSupplementSewerBscPlan() {
|
||||
body: SewerBscPlanApplySaveRequestDto;
|
||||
}) => sewerBscPlanService.submitReqSupplement(id, chgCycl, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findById", id],
|
||||
queryKey: sewerBscPlanKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -131,9 +137,9 @@ export function useTechReviewSewerBscPlan() {
|
||||
mutationFn: ({ id, body }: { id: string; body: SewerBscPlanApplySaveRequestDto }) =>
|
||||
sewerBscPlanService.techReview(id, body),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanBaseKey });
|
||||
queryClient.invalidateQueries({ queryKey: sewerBscPlanKeys.all });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [...sewerBscPlanBaseKey, "findById", id],
|
||||
queryKey: sewerBscPlanKeys.detail(id),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { sewerBscPlanBaseKey } from "./api/queries";
|
||||
export { sewerBscPlanKeys } from "./api/queries";
|
||||
export {
|
||||
useDeleteSewerBscPlan,
|
||||
useSaveApplySewerBscPlan,
|
||||
|
||||
Reference in New Issue
Block a user