Skip to content

Commit

Permalink
Merge pull request #210 from Step3-kakao-tech-campus/feat/#138
Browse files Browse the repository at this point in the history
feat: 수정하기 라디오버튼 중성화상태 문제 해결
  • Loading branch information
JeonDoGyun authored Nov 11, 2023
2 parents 66f096e + c8e8499 commit 40e1fed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/pages/update/components/UpdateRegisterForm.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
28 changes: 22 additions & 6 deletions src/pages/update/components/UpdateTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>로딩중</div>;
}

if (isError) {
return <div>Error: {isError}</div>;
}
Expand Down

0 comments on commit 40e1fed

Please sign in to comment.