From c8e8499d80e543ecc7829b8a9940445bafa159a8 Mon Sep 17 00:00:00 2001 From: LimSumi Date: Sat, 11 Nov 2023 20:09:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=88=98=EC=A0=95=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EB=9D=BC=EB=94=94=EC=98=A4=EB=B2=84=ED=8A=BC=20=EC=A4=91?= =?UTF-8?q?=EC=84=B1=ED=99=94=EC=83=81=ED=83=9C=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../update/components/UpdateRegisterForm.tsx | 3 +- .../update/components/UpdateTemplate.tsx | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/pages/update/components/UpdateRegisterForm.tsx b/src/pages/update/components/UpdateRegisterForm.tsx index bfb0aef5..6a36d572 100644 --- a/src/pages/update/components/UpdateRegisterForm.tsx +++ b/src/pages/update/components/UpdateRegisterForm.tsx @@ -1,10 +1,11 @@ -import { useSetRecoilState } from 'recoil'; +import { useRecoilState, useSetRecoilState } from 'recoil'; import registerState, { RegisterType } from 'recoil/registerState'; import VMRegisterForm from './VUpdateRegisterForm'; import { PetProps } from '../updateType'; const UpdateRegisterForm = ({ petInfo }: PetProps) => { const setPetInfoState = useSetRecoilState(registerState); + const PET_INFO_REQUIRED_KEY: (keyof RegisterType)[] = [ 'age', 'name', diff --git a/src/pages/update/components/UpdateTemplate.tsx b/src/pages/update/components/UpdateTemplate.tsx index 3d8e153b..39f7ab97 100644 --- a/src/pages/update/components/UpdateTemplate.tsx +++ b/src/pages/update/components/UpdateTemplate.tsx @@ -37,18 +37,34 @@ const UpdateTemplate = () => { return res; }; - const { isLoading, isError } = useQuery({ + const { isError } = useQuery({ queryKey: ['pet-update'], queryFn: () => getPetInfo(), onSuccess: (fetchedData) => { - const { profileImageUrl, profileShortFormUrl, ...rest } = fetchedData; - setUpdateState({ ...rest, isComplete: true }); + const { + profileImageUrl, + profileShortFormUrl, + neutralizationStatus, + ...rest + } = fetchedData; + let updatedNeutralizationStatus; + if (neutralizationStatus === '했어요') { + updatedNeutralizationStatus = 'YES'; + } else if (updatedNeutralizationStatus === '안했어요') { + updatedNeutralizationStatus = 'NO'; + } else { + updatedNeutralizationStatus = 'UNKNOWN'; + } + + setUpdateState({ + ...rest, + neutralizationStatus: updatedNeutralizationStatus, + isComplete: true, + }); }, suspense: true, }); - if (isLoading) { - return
로딩중
; - } + if (isError) { return
Error: {isError}
; }