From cdfe211203d0d625d1e2806fa9d5a53079ca96a9 Mon Sep 17 00:00:00 2001 From: keyy1315 Date: Thu, 12 Jun 2025 09:02:40 +0900 Subject: [PATCH] fix: fixed error for popup element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 수정/작성 제출 시 팝업 올라오지 않는 문제 해결 --- src/components/survey-sale/detail/ButtonForm.tsx | 5 ++++- src/components/survey-sale/detail/DetailForm.tsx | 4 ++-- src/hooks/useSurvey.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/survey-sale/detail/ButtonForm.tsx b/src/components/survey-sale/detail/ButtonForm.tsx index 044a1d4..b7d1e5d 100644 --- a/src/components/survey-sale/detail/ButtonForm.tsx +++ b/src/components/survey-sale/detail/ButtonForm.tsx @@ -146,6 +146,9 @@ export default function ButtonForm({ mode, setMode, data }: ButtonFormProps) { }) if (!isUpdatingSurvey) { setMode('READ') + if (isSubmitProcess) { + popupController.setSurveySaleSubmitPopup(true) + } } } else { /** 제출 로직인 경우 search param 추가 */ @@ -249,7 +252,7 @@ export default function ButtonForm({ mode, setMode, data }: ButtonFormProps) { ) } -// Button Components +/** Button Components */ const ListButton = () => { const router = useRouter() return ( diff --git a/src/components/survey-sale/detail/DetailForm.tsx b/src/components/survey-sale/detail/DetailForm.tsx index 0f73c46..06511c2 100644 --- a/src/components/survey-sale/detail/DetailForm.tsx +++ b/src/components/survey-sale/detail/DetailForm.tsx @@ -97,11 +97,11 @@ export default function DetailForm() { /** 제출 팝업 처리 - createSurvey 이후 popup 처리 시 노드 삽입 오류로 인해 별도 처리 */ useEffect(() => { const show = searchParams.get('show') - if (show === 'true') { + if (show === 'true' && !isLoadingSurveyDetail) { popupController.setSurveySaleSubmitPopup(true) router.replace(pathname) } - }, [searchParams, pathname]) + }, [searchParams, pathname, isLoadingSurveyDetail]) /** 세션 데이터가 변경될 때 기본 정보 업데이트 */ useEffect(() => { diff --git a/src/hooks/useSurvey.ts b/src/hooks/useSurvey.ts index 5e50e30..84f6cfa 100644 --- a/src/hooks/useSurvey.ts +++ b/src/hooks/useSurvey.ts @@ -110,19 +110,19 @@ export function useSurvey( const status = error.response?.status alert(error.response?.data.error) switch (status) { - // session 없는 경우 + /** session 없는 경우 */ case 401: router.replace('/login') break - // 조회 권한 없는 경우 + /** 조회 권한 없는 경우 */ case 403: router.replace('/survey-sale') break - // 데이터 DB상 존재하지 않는 경우 + /** 데이터 DB상 존재하지 않는 경우 */ case 404: router.replace('/survey-sale') break - // 서버 오류 + /** 서버 오류 */ case 500: router.back() break @@ -268,8 +268,8 @@ export function useSurvey( * @throws {Error} id가 없는 경우 에러 발생 * * @example - * // 삭제 성공 시 목록 데이터만 갱신하고, 상세 데이터는 갱신하지 않음 - * // 상세 데이터를 갱신하면 404 에러가 발생할 수 있음 + * + * */ const { mutateAsync: deleteSurvey, isPending: isDeletingSurvey } = useMutation({ mutationFn: async () => {