[as] feat: 재원협의 쿼리 무효화 로직 수정
This commit is contained in:
@@ -12,8 +12,8 @@ interface FnrsDetailGateProps {
|
||||
|
||||
function FnrsDetailGate({ id }: FnrsDetailGateProps) {
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const { data, isLoading, isError } = useFnrsCnsltnMng(id);
|
||||
const shouldRedirectToEdit = canEditPbadmsDoc({
|
||||
const { data, isLoading, isFetching, isError } = useFnrsCnsltnMng(id);
|
||||
const canEdit = canEditPbadmsDoc({
|
||||
docSeComCd: "FNRS",
|
||||
prgrsSttsComCd: data?.detDto?.prgrsSttsComCd,
|
||||
rgtr: data?.detDto?.rgtr,
|
||||
@@ -22,9 +22,9 @@ function FnrsDetailGate({ id }: FnrsDetailGateProps) {
|
||||
|
||||
return (
|
||||
<PbadmsDetailGate
|
||||
isPending={!userInfo || isLoading}
|
||||
isPending={!userInfo || isLoading || isFetching}
|
||||
isError={isError}
|
||||
shouldRedirectToEdit={Boolean(userInfo) && shouldRedirectToEdit}
|
||||
shouldRedirectToEdit={!isFetching && Boolean(userInfo) && canEdit}
|
||||
editHref={`/fnrs-cnsltn/${id}/edit`}
|
||||
>
|
||||
<FnrsViewPage id={id} />
|
||||
|
||||
@@ -145,7 +145,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
const docNo = initialData?.detDto?.fnrsCnsltnDocNo;
|
||||
const payload = buildFormPayload(data, beforePrgrsSttsComCd);
|
||||
if (!docNo || !payload) return undefined;
|
||||
debugger;
|
||||
|
||||
return fnrsCnsltnMngService.submitSupplement(docNo, payload);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
if (!result) return;
|
||||
|
||||
alert("보완완료 처리되었습니다.");
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push(`/fnrs-cnsltn/${docNo}`);
|
||||
} catch (error) {
|
||||
console.error("보완완료 실패:", error);
|
||||
@@ -191,7 +191,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
if (!fnrsCnsltnDocNo) return;
|
||||
|
||||
alert("저장되었습니다.");
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push(`/fnrs-cnsltn/${fnrsCnsltnDocNo}/edit`);
|
||||
} catch (error) {
|
||||
console.error("저장 실패:", error);
|
||||
@@ -220,7 +220,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
if (!fnrsCnsltnDocNo) return;
|
||||
|
||||
alert("신청 완료되었습니다.");
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push(`/fnrs-cnsltn/${fnrsCnsltnDocNo}`);
|
||||
} catch (error) {
|
||||
console.error("신청 실패:", error);
|
||||
@@ -249,7 +249,7 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps)
|
||||
setIsSubmitting(true);
|
||||
await fnrsCnsltnMngService.remove(docNo);
|
||||
alert("삭제되었습니다.");
|
||||
queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
await queryClient.invalidateQueries({ queryKey: fnrsCnsltnKeys.all });
|
||||
router.push("/fnrs-cnsltn");
|
||||
} catch (error) {
|
||||
console.error("삭제 실패:", error);
|
||||
|
||||
@@ -44,9 +44,9 @@ function PbadmsDetailGate({
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (!shouldRedirectToEdit) return;
|
||||
if (isPending || !shouldRedirectToEdit) return;
|
||||
router.replace(editHref);
|
||||
}, [editHref, router, shouldRedirectToEdit]);
|
||||
}, [editHref, isPending, router, shouldRedirectToEdit]);
|
||||
|
||||
if (isPending || shouldRedirectToEdit) return <DetailSkeleton />;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user