134 lines
4.3 KiB
TypeScript
134 lines
4.3 KiB
TypeScript
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
|
import type {
|
|
DocPrgrsUpdateRequestDto,
|
|
FnrsCnsltnApplySaveRequestDto,
|
|
FnrsCnsltnMngSaveRequestDto,
|
|
FnrsCnsltnMngSearchDto,
|
|
FnrsCnsltnMngUpdateRequestDto,
|
|
} from "../model/fnrs-cnsltn-interface";
|
|
|
|
import { fnrsCnsltnMngService } from "./fnrs-cnsltn-service";
|
|
|
|
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: [...fnrsCnsltnKeys.list(), params],
|
|
queryFn: () => fnrsCnsltnMngService.findPage(params),
|
|
});
|
|
}
|
|
|
|
export function useFnrsCnsltnMng(fnrsCnsltnDocNo: string | null | undefined) {
|
|
return useQuery({
|
|
queryKey: fnrsCnsltnKeys.detail(fnrsCnsltnDocNo!),
|
|
queryFn: () => fnrsCnsltnMngService.findById(fnrsCnsltnDocNo!),
|
|
enabled: Boolean(fnrsCnsltnDocNo),
|
|
});
|
|
}
|
|
|
|
export function useSaveFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: FnrsCnsltnMngSaveRequestDto) => fnrsCnsltnMngService.save(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useSaveApplyFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: FnrsCnsltnApplySaveRequestDto) => fnrsCnsltnMngService.saveApply(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useUpdateFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({
|
|
fnrsCnsltnDocNo,
|
|
body,
|
|
}: {
|
|
fnrsCnsltnDocNo: string;
|
|
body: FnrsCnsltnMngUpdateRequestDto;
|
|
}) => fnrsCnsltnMngService.update(fnrsCnsltnDocNo, body),
|
|
onSuccess: (_data, { fnrsCnsltnDocNo }) => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: fnrsCnsltnKeys.detail(fnrsCnsltnDocNo),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useTechReviewFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
|
fnrsCnsltnMngService.techReview(id, body),
|
|
onSuccess: (_data, { id }) => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: fnrsCnsltnKeys.detail(id),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useSubmitSupplementFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
|
fnrsCnsltnMngService.submitSupplement(id, body),
|
|
onSuccess: (_data, { id }) => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: fnrsCnsltnKeys.detail(id),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useSubmitReqSupplementFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: ({ id, body }: { id: string; body: FnrsCnsltnApplySaveRequestDto }) =>
|
|
fnrsCnsltnMngService.submitReqSupplement(id, body),
|
|
onSuccess: (_data, { id }) => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
queryClient.invalidateQueries({
|
|
queryKey: fnrsCnsltnKeys.detail(id),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useDeleteFnrsCnsltnMng() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (fnrsCnsltnDocNo: string) => fnrsCnsltnMngService.remove(fnrsCnsltnDocNo),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
},
|
|
});
|
|
}
|
|
|
|
export function useChangePrgrsSttsComCd() {
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: (body: DocPrgrsUpdateRequestDto) => fnrsCnsltnMngService.changePrgrsSttsComCd(body),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
|
},
|
|
});
|
|
}
|