429 lines
14 KiB
TypeScript
429 lines
14 KiB
TypeScript
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
|
import type {
|
|
DesignCnstnApplySaveRequestDto,
|
|
DesignCnstnMngSaveRequestDto,
|
|
DesignCnstnRvwOpnnSaveRequestDto,
|
|
} from "../model/design-cnstn-apply-payload-schema";
|
|
import type {
|
|
DesignCnstnBizCstSaveRequestDto,
|
|
DesignCnstnBizCstSearchDto,
|
|
DesignCnstnBizCstUpdateRequestDto,
|
|
} from "../model/design-cnstn-biz-cst-interface";
|
|
import type {
|
|
DesignCnstnBizSclSaveRequestDto,
|
|
DesignCnstnBizSclSearchDto,
|
|
DesignCnstnBizSclUpdateRequestDto,
|
|
} from "../model/design-cnstn-biz-scl-interface";
|
|
import type {
|
|
DesignCnstnEsntlAtchFileSaveRequestDto,
|
|
DesignCnstnEsntlAtchFileSearchDto,
|
|
DesignCnstnEsntlAtchFileUpdateRequestDto,
|
|
} from "../model/design-cnstn-esntl-atch-file-interface";
|
|
import type {
|
|
DesignCnstnMngSearchDto,
|
|
DesignCnstnMngUpdateRequestDto,
|
|
} from "../model/design-cnstn-mng-interface";
|
|
import type {
|
|
DesignCnstnRvwOpnnSearchDto,
|
|
DesignCnstnRvwOpnnUpdateRequestDto,
|
|
} from "../model/design-cnstn-rvw-opnn-interface";
|
|
|
|
import { designCnstnBizCstService } from "./design-cnstn-biz-cst-service";
|
|
import { designCnstnBizSclService } from "./design-cnstn-biz-scl-service";
|
|
import { designCnstnEsntlAtchFileService } from "./design-cnstn-esntl-atch-file-service";
|
|
import { designCnstnMngService } from "./design-cnstn-mng-service";
|
|
import { designCnstnRvwOpnnService } from "./design-cnstn-rvw-opnn-service";
|
|
|
|
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: [...designCnstnKeys.list(), params],
|
|
queryFn: () => designCnstnMngService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useDesignCnstnMng(id: string | null | undefined) {
|
|
return useQuery({
|
|
queryKey: designCnstnKeys.detail(id!),
|
|
queryFn: () => designCnstnMngService.findById(id!),
|
|
enabled: Boolean(id),
|
|
staleTime: 0,
|
|
refetchOnMount: "always",
|
|
});
|
|
}
|
|
|
|
export function useSaveDesignCnstnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnMngSaveRequestDto) => designCnstnMngService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useSaveApplyDesignCnstnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnApplySaveRequestDto) => designCnstnMngService.saveApply(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateDesignCnstnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, body }: { id: string; body: DesignCnstnMngUpdateRequestDto }) =>
|
|
designCnstnMngService.update(id, body),
|
|
onSuccess: (_data, { id }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnKeys.detail(id),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useTechReviewDesignCnstnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, body }: { id: string; body: DesignCnstnApplySaveRequestDto }) =>
|
|
designCnstnMngService.techReview(id, body),
|
|
onSuccess: (_data, { id }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnKeys.detail(id),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteDesignCnstnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (id: string) => designCnstnMngService.delete(id),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
/* ─── DesignCnstnBizCst ─── */
|
|
|
|
export function useDesignCnstnBizCstPage(params: DesignCnstnBizCstSearchDto) {
|
|
return useQuery({
|
|
queryKey: [...designCnstnBizCstKeys.list(), params],
|
|
queryFn: () => designCnstnBizCstService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useDesignCnstnBizCst(
|
|
designCnstnDocNo: string | null | undefined,
|
|
acntgSeCd: string | null | undefined,
|
|
) {
|
|
return useQuery({
|
|
queryKey: designCnstnBizCstKeys.detail(designCnstnDocNo!, acntgSeCd!),
|
|
queryFn: () => designCnstnBizCstService.findById(designCnstnDocNo!, acntgSeCd!),
|
|
enabled: Boolean(designCnstnDocNo && acntgSeCd),
|
|
});
|
|
}
|
|
|
|
export function useSaveDesignCnstnBizCst() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnBizCstSaveRequestDto) => designCnstnBizCstService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateDesignCnstnBizCst() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
acntgSeCd,
|
|
body,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
acntgSeCd: string;
|
|
body: DesignCnstnBizCstUpdateRequestDto;
|
|
}) => designCnstnBizCstService.update(designCnstnDocNo, acntgSeCd, body),
|
|
onSuccess: (_data, { designCnstnDocNo, acntgSeCd }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnBizCstKeys.detail(designCnstnDocNo, acntgSeCd),
|
|
});
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteDesignCnstnBizCst() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
acntgSeCd,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
acntgSeCd: string;
|
|
}) => designCnstnBizCstService.delete(designCnstnDocNo, acntgSeCd),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizCstKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
/* ─── DesignCnstnBizScl ─── */
|
|
|
|
export function useDesignCnstnBizSclPage(params: DesignCnstnBizSclSearchDto) {
|
|
return useQuery({
|
|
queryKey: [...designCnstnBizSclKeys.list(), params],
|
|
queryFn: () => designCnstnBizSclService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useDesignCnstnBizScl(
|
|
designCnstnDocNo: string | null | undefined,
|
|
cnstpSeCd: string | null | undefined,
|
|
) {
|
|
return useQuery({
|
|
queryKey: designCnstnBizSclKeys.detail(designCnstnDocNo!, cnstpSeCd!),
|
|
queryFn: () => designCnstnBizSclService.findById(designCnstnDocNo!, cnstpSeCd!),
|
|
enabled: Boolean(designCnstnDocNo && cnstpSeCd),
|
|
});
|
|
}
|
|
|
|
export function useSaveDesignCnstnBizScl() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnBizSclSaveRequestDto) => designCnstnBizSclService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateDesignCnstnBizScl() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
cnstpSeCd,
|
|
body,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
cnstpSeCd: string;
|
|
body: DesignCnstnBizSclUpdateRequestDto;
|
|
}) => designCnstnBizSclService.update(designCnstnDocNo, cnstpSeCd, body),
|
|
onSuccess: (_data, { designCnstnDocNo, cnstpSeCd }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnBizSclKeys.detail(designCnstnDocNo, cnstpSeCd),
|
|
});
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteDesignCnstnBizScl() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
cnstpSeCd,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
cnstpSeCd: string;
|
|
}) => designCnstnBizSclService.delete(designCnstnDocNo, cnstpSeCd),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnBizSclKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
/* ─── DesignCnstnEsntlAtchFile ─── */
|
|
|
|
export function useDesignCnstnEsntlAtchFilePage(params: DesignCnstnEsntlAtchFileSearchDto) {
|
|
return useQuery({
|
|
queryKey: [...designCnstnEsntlAtchFileKeys.list(), params],
|
|
queryFn: () => designCnstnEsntlAtchFileService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useDesignCnstnEsntlAtchFile(
|
|
designCnstnDocNo: string | null | undefined,
|
|
esntlAtchFileId: string | null | undefined,
|
|
) {
|
|
return useQuery({
|
|
queryKey: designCnstnEsntlAtchFileKeys.detail(designCnstnDocNo!, esntlAtchFileId!),
|
|
queryFn: () => designCnstnEsntlAtchFileService.findById(designCnstnDocNo!, esntlAtchFileId!),
|
|
enabled: Boolean(designCnstnDocNo && esntlAtchFileId),
|
|
});
|
|
}
|
|
|
|
export function useSaveDesignCnstnEsntlAtchFile() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnEsntlAtchFileSaveRequestDto) =>
|
|
designCnstnEsntlAtchFileService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateDesignCnstnEsntlAtchFile() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
esntlAtchFileId,
|
|
body,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
esntlAtchFileId: string;
|
|
body: DesignCnstnEsntlAtchFileUpdateRequestDto;
|
|
}) => designCnstnEsntlAtchFileService.update(designCnstnDocNo, esntlAtchFileId, body),
|
|
onSuccess: (_data, { designCnstnDocNo, esntlAtchFileId }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnEsntlAtchFileKeys.detail(designCnstnDocNo, esntlAtchFileId),
|
|
});
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteDesignCnstnEsntlAtchFile() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
esntlAtchFileId,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
esntlAtchFileId: string;
|
|
}) => designCnstnEsntlAtchFileService.delete(designCnstnDocNo, esntlAtchFileId),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnEsntlAtchFileKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
/* ─── DesignCnstnRvwOpnn ─── */
|
|
|
|
export function useDesignCnstnRvwOpnnPage(params: DesignCnstnRvwOpnnSearchDto) {
|
|
return useQuery({
|
|
queryKey: [...designCnstnRvwOpnnKeys.list(), params],
|
|
queryFn: () => designCnstnRvwOpnnService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useDesignCnstnRvwOpnn(
|
|
designCnstnDocNo: string | null | undefined,
|
|
rvwOpnnSn: number | null | undefined,
|
|
) {
|
|
return useQuery({
|
|
queryKey: designCnstnRvwOpnnKeys.detail(designCnstnDocNo!, rvwOpnnSn!),
|
|
queryFn: () => designCnstnRvwOpnnService.findById(designCnstnDocNo!, rvwOpnnSn!),
|
|
enabled: Boolean(designCnstnDocNo && rvwOpnnSn != null),
|
|
});
|
|
}
|
|
|
|
export function useSaveDesignCnstnRvwOpnn() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DesignCnstnRvwOpnnSaveRequestDto) => designCnstnRvwOpnnService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateDesignCnstnRvwOpnn() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
rvwOpnnSn,
|
|
body,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
rvwOpnnSn: number;
|
|
body: DesignCnstnRvwOpnnUpdateRequestDto;
|
|
}) => designCnstnRvwOpnnService.update(designCnstnDocNo, rvwOpnnSn, body),
|
|
onSuccess: (_data, { designCnstnDocNo, rvwOpnnSn }) => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: designCnstnRvwOpnnKeys.detail(designCnstnDocNo, rvwOpnnSn),
|
|
});
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteDesignCnstnRvwOpnn() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
designCnstnDocNo,
|
|
rvwOpnnSn,
|
|
}: {
|
|
designCnstnDocNo: string;
|
|
rvwOpnnSn: number;
|
|
}) => designCnstnRvwOpnnService.delete(designCnstnDocNo, rvwOpnnSn),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: designCnstnRvwOpnnKeys.all });
|
|
queryClient.invalidateQueries({ queryKey: designCnstnKeys.all });
|
|
},
|
|
});
|
|
}
|