[as fr] 재원협의,설치인가 보완완료 직후 버튼 체크 로직 실시간 반영으로 변경함
This commit is contained in:
@@ -64,8 +64,11 @@ export function useSaveApplyFnrsCnsltnMng() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (body: FnrsCnsltnApplySaveRequestDto) => fnrsCnsltnMngService.saveApply(body),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
queryClient.removeQueries({ queryKey: fnrsCnsltnKeys.detail(data) });
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all, refetchType: "all" });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -137,10 +140,8 @@ export function useSubmitSupplementFnrsCnsltnMng() {
|
||||
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),
|
||||
});
|
||||
queryClient.removeQueries({ queryKey: fnrsCnsltnKeys.detail(id) });
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all, refetchType: "all" });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,8 +71,11 @@ export function useInstlSncnSaveApply() {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: InstlSncnApplySaveRequestDto) => instlSncnService.saveApply(payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.all });
|
||||
onSuccess: (data) => {
|
||||
if (data) {
|
||||
queryClient.removeQueries({ queryKey: instlSncnKeys.detail(data) });
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.all, refetchType: "all" });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -110,8 +113,8 @@ export function useInstlSncnSubmitSupplement() {
|
||||
mutationFn: ({ id, payload }: { id: string; payload: InstlSncnApplySaveRequestDto }) =>
|
||||
instlSncnService.submitSupplement(id, payload),
|
||||
onSuccess: (_, variables) => {
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.all });
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.detail(variables.id) });
|
||||
queryClient.removeQueries({ queryKey: instlSncnKeys.detail(variables.id) });
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.all, refetchType: "all" });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ interface FnrsDetailGateProps {
|
||||
|
||||
function FnrsDetailGate({ id }: FnrsDetailGateProps) {
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const { data, isLoading, isError } = useFnrsCnsltnMng(id);
|
||||
const { data, isLoading, isFetching, isError } = useFnrsCnsltnMng(id);
|
||||
const canEdit = canEditPbadmsDoc({
|
||||
docSeComCd: "FNRS",
|
||||
prgrsSttsComCd: data?.detDto?.prgrsSttsComCd,
|
||||
@@ -22,7 +22,7 @@ function FnrsDetailGate({ id }: FnrsDetailGateProps) {
|
||||
|
||||
return (
|
||||
<PbadmsDetailGate
|
||||
isPending={!userInfo || isLoading}
|
||||
isPending={!userInfo || isLoading || isFetching}
|
||||
isError={isError}
|
||||
shouldRedirectToEdit={Boolean(userInfo) && canEdit}
|
||||
editHref={`/fnrs-cnsltn/${id}/edit`}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useUserStore, withListQs } from "@/shared/lib";
|
||||
import { useFnrsCnsltnMng } from "@/entities/fnrs-cnsltn";
|
||||
import { canEditPbadmsDoc } from "@/widgets/pbadms-sprt";
|
||||
import { Skeleton } from "@common/components";
|
||||
|
||||
import { FnrsFormPage } from "./fnrs-form-page";
|
||||
@@ -10,9 +15,25 @@ interface FnrsEditPageProps {
|
||||
}
|
||||
|
||||
function FnrsEditPage({ id }: FnrsEditPageProps) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const { data, isLoading } = useFnrsCnsltnMng(id);
|
||||
|
||||
if (isLoading) {
|
||||
const canEdit = canEditPbadmsDoc({
|
||||
docSeComCd: "FNRS",
|
||||
prgrsSttsComCd: data?.detDto?.prgrsSttsComCd,
|
||||
rgtr: data?.detDto?.rgtr,
|
||||
loggedInUserUnqId: userInfo?.userUnqId,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoading || !data?.detDto || !userInfo) return;
|
||||
if (!canEdit) {
|
||||
router.replace(withListQs(`/fnrs-cnsltn/${id}`));
|
||||
}
|
||||
}, [canEdit, data?.detDto, id, isLoading, router, userInfo]);
|
||||
|
||||
if (isLoading || (Boolean(data?.detDto) && !canEdit && Boolean(userInfo))) {
|
||||
return (
|
||||
<div className="mt-6 space-y-6 px-4">
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -70,7 +70,9 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [isPwrkCnsltnDocMngOpen, setIsPwrkCnsltnDocMngOpen] = useState(false);
|
||||
const isEditMode = mode === "edit";
|
||||
const isSplmntPrgrsStts = initialData?.detDto?.prgrsSttsComCd === "SL";
|
||||
const prgrsSttsComCd = initialData?.detDto?.prgrsSttsComCd ?? "";
|
||||
const isDraftStatus = !isEditMode || prgrsSttsComCd === "SV" || prgrsSttsComCd === "";
|
||||
const isSplmntPrgrsStts = isEditMode && prgrsSttsComCd === "SL";
|
||||
const fnrsCnsltnDocNo = initialData?.detDto?.fnrsCnsltnDocNo;
|
||||
|
||||
const { data: pwrkCnsltnData } = usePwrkCnsltnMngByUpDocNo(
|
||||
@@ -153,8 +155,9 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
if (!result) return;
|
||||
|
||||
alert("보완 완료 처리되었습니다.");
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push(withListQs(`/fnrs-cnsltn/${docNo}`));
|
||||
queryClient.removeQueries({ queryKey: fnrsCnsltnKeys.detail(docNo) });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all, refetchType: "all" });
|
||||
router.replace(withListQs(`/fnrs-cnsltn/${docNo}`));
|
||||
} catch (error) {
|
||||
console.error("보완 완료 실패:", error);
|
||||
alert("보완 완료 처리 중 오류가 발생했습니다.");
|
||||
@@ -206,8 +209,9 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
if (!fnrsCnsltnDocNo) return;
|
||||
|
||||
alert("신청 완료되었습니다.");
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push(withListQs(`/fnrs-cnsltn/${fnrsCnsltnDocNo}`));
|
||||
queryClient.removeQueries({ queryKey: fnrsCnsltnKeys.detail(fnrsCnsltnDocNo) });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all, refetchType: "all" });
|
||||
router.replace(withListQs(`/fnrs-cnsltn/${fnrsCnsltnDocNo}`));
|
||||
} catch (error) {
|
||||
console.error("신청 실패:", error);
|
||||
alert("신청 중 오류가 발생했습니다.");
|
||||
@@ -294,7 +298,27 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
>
|
||||
목록
|
||||
</Button>
|
||||
{!isSplmntPrgrsStts ? (
|
||||
{isSplmntPrgrsStts ? (
|
||||
<>
|
||||
{hasCompletedDraft ? (
|
||||
<Button
|
||||
color="orange"
|
||||
type="button"
|
||||
onClick={() => setIsPwrkCnsltnDocMngOpen(true)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
실무협의서 관리
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
type="button"
|
||||
onClick={form.handleSubmit(onSplmntCmptn)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
보완 완료
|
||||
</Button>
|
||||
</>
|
||||
) : isDraftStatus ? (
|
||||
<>
|
||||
<Button type="submit" disabled={isSubmitting}>
|
||||
저장
|
||||
@@ -320,27 +344,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{hasCompletedDraft ? (
|
||||
<Button
|
||||
color="orange"
|
||||
type="button"
|
||||
onClick={() => setIsPwrkCnsltnDocMngOpen(true)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
실무협의서 관리
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
type="button"
|
||||
onClick={form.handleSubmit(onSplmntCmptn)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
보완 완료
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,7 @@ interface InstlSncnDetailGateProps {
|
||||
|
||||
function InstlSncnDetailGate({ id }: InstlSncnDetailGateProps) {
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const { data, isLoading, isError } = useInstlSncnDetail(id);
|
||||
const { data, isLoading, isFetching, isError } = useInstlSncnDetail(id);
|
||||
const shouldRedirectToEdit = canEditPbadmsDoc({
|
||||
docSeComCd: "INSTL",
|
||||
prgrsSttsComCd: data?.detDto.prgrsSttsComCd,
|
||||
@@ -22,7 +22,7 @@ function InstlSncnDetailGate({ id }: InstlSncnDetailGateProps) {
|
||||
|
||||
return (
|
||||
<PbadmsDetailGate
|
||||
isPending={!userInfo || isLoading}
|
||||
isPending={!userInfo || isLoading || isFetching}
|
||||
isError={isError}
|
||||
shouldRedirectToEdit={Boolean(userInfo) && shouldRedirectToEdit}
|
||||
editHref={`/instl-sncn/${id}/edit`}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useUserStore, withListQs } from "@/shared/lib";
|
||||
import { useInstlSncnDetail } from "@/entities/instl-sncn";
|
||||
import { canEditPbadmsDoc } from "@/widgets/pbadms-sprt";
|
||||
import { Skeleton } from "@common/components";
|
||||
|
||||
import { InstlFormPage } from "./instl-form-page";
|
||||
@@ -10,9 +15,25 @@ interface InstlEditPageProps {
|
||||
}
|
||||
|
||||
function InstlEditPage({ id }: InstlEditPageProps) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const { data, isError, isLoading } = useInstlSncnDetail(id);
|
||||
|
||||
if (isLoading) {
|
||||
const canEdit = canEditPbadmsDoc({
|
||||
docSeComCd: "INSTL",
|
||||
prgrsSttsComCd: data?.detDto.prgrsSttsComCd,
|
||||
rgtr: data?.detDto.rgtr,
|
||||
loggedInUserUnqId: userInfo?.userUnqId,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoading || !data?.detDto || !userInfo) return;
|
||||
if (!canEdit) {
|
||||
router.replace(withListQs(`/instl-sncn/${id}`));
|
||||
}
|
||||
}, [canEdit, data?.detDto, id, isLoading, router, userInfo]);
|
||||
|
||||
if (isLoading || (Boolean(data?.detDto) && !canEdit && Boolean(userInfo))) {
|
||||
return (
|
||||
<div className="mt-6 space-y-6 px-4">
|
||||
<div className="space-y-2">
|
||||
|
||||
@@ -59,7 +59,9 @@ function InstlFormPage({ mode, initialData, createDefaults }: InstlFormPageProps
|
||||
const alert = useAlertStore((state) => state.setMessage);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const isEditMode = mode === "edit";
|
||||
const isSplmntPrgrsStts = initialData?.detDto.prgrsSttsComCd === "SL";
|
||||
const prgrsSttsComCd = initialData?.detDto.prgrsSttsComCd ?? "";
|
||||
const isDraftStatus = !isEditMode || prgrsSttsComCd === "SV" || prgrsSttsComCd === "";
|
||||
const isSplmntPrgrsStts = isEditMode && prgrsSttsComCd === "SL";
|
||||
|
||||
const { data: essentialFiles = [] } = useEsntlAtchFileMngTree({ docSeComCd: "INSTL" });
|
||||
|
||||
@@ -115,8 +117,9 @@ function InstlFormPage({ mode, initialData, createDefaults }: InstlFormPageProps
|
||||
if (!result) return;
|
||||
|
||||
alert("보완 완료 처리되었습니다.");
|
||||
await queryClient.invalidateQueries({ queryKey: instlSncnKeys.all });
|
||||
router.push(withListQs(`/instl-sncn/${docNo}`));
|
||||
queryClient.removeQueries({ queryKey: instlSncnKeys.detail(docNo) });
|
||||
await queryClient.invalidateQueries({ queryKey: instlSncnKeys.all, refetchType: "all" });
|
||||
router.replace(withListQs(`/instl-sncn/${docNo}`));
|
||||
} catch (error) {
|
||||
console.error("보완 완료 실패:", error);
|
||||
alert("보완 완료 처리 중 오류가 발생했습니다.");
|
||||
@@ -163,8 +166,9 @@ function InstlFormPage({ mode, initialData, createDefaults }: InstlFormPageProps
|
||||
if (!instlSncnDocNo) return;
|
||||
|
||||
alert("신청 완료되었습니다.");
|
||||
router.push(withListQs(`/instl-sncn/${instlSncnDocNo}`));
|
||||
queryClient.invalidateQueries({ queryKey: instlSncnKeys.all });
|
||||
queryClient.removeQueries({ queryKey: instlSncnKeys.detail(instlSncnDocNo) });
|
||||
await queryClient.invalidateQueries({ queryKey: instlSncnKeys.all, refetchType: "all" });
|
||||
router.replace(withListQs(`/instl-sncn/${instlSncnDocNo}`));
|
||||
} catch (error) {
|
||||
console.error("신청 실패:", error);
|
||||
alert("신청 중 오류가 발생했습니다.");
|
||||
@@ -239,7 +243,15 @@ function InstlFormPage({ mode, initialData, createDefaults }: InstlFormPageProps
|
||||
>
|
||||
목록
|
||||
</Button>
|
||||
{!isSplmntPrgrsStts ? (
|
||||
{isSplmntPrgrsStts ? (
|
||||
<Button
|
||||
type="button"
|
||||
onClick={form.handleSubmit(onSplmntCmptn)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
보완 완료
|
||||
</Button>
|
||||
) : isDraftStatus ? (
|
||||
<>
|
||||
<Button type="submit" disabled={isSubmitting}>
|
||||
저장
|
||||
@@ -265,15 +277,7 @@ function InstlFormPage({ mode, initialData, createDefaults }: InstlFormPageProps
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
type="button"
|
||||
onClick={form.handleSubmit(onSplmntCmptn)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
보완 완료
|
||||
</Button>
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user