Skip to content

Commit

Permalink
Merge pull request #108 from Step3-kakao-tech-campus/feat/#45
Browse files Browse the repository at this point in the history
fix: registerState에 오각형 객체 중복 해결
  • Loading branch information
hjiwon authored Oct 14, 2023
2 parents 686ee83 + 379c208 commit 78c1531
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
12 changes: 10 additions & 2 deletions src/commons/modals/RegisterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const RegisterModal = ({
isError,
data,
}: RegisterModalProps) => {
console.log(data);
if (isError || data?.success === false) {
return (
<div
Expand All @@ -35,13 +36,20 @@ const RegisterModal = ({
</button>
</div>
<span className="text-2xl text-brand-color">등록에 실패했습니다</span>
<div className="flex w-2/3 justify-center mt-8">
<div className="text-red-600">{data.error.message}</div>
<div className="flex w-2/3 justify-between mt-8">
<button
className="bg-brand-color rounded-md font-bold text-white w-16 py-2"
className="text-brand-color rounded-md font-bold border border-brand-color w-16 py-2"
onClick={handleRegisterMoreButtonClick}
>
확인
</button>
<button
className="bg-brand-color rounded-md font-bold text-white w-20 py-2"
onClick={handleRegisterButtonClick}
>
다시하기
</button>
</div>
</div>
</div>
Expand Down
13 changes: 3 additions & 10 deletions src/pages/register/RegisterHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,29 @@ const RegisterHeader = () => {
};

// 등록하기 관련
console.log(getCookie('loginToken'));
const postPet = async (formData: FormData) => {
const loginToken = getCookie('loginToken');
console.log(`Bearer ${loginToken}`);
const res = await fetch(`${process.env.REACT_APP_URI}/pet`, {
method: 'POST',
body: formData,
headers: {
Authorization: `Bearer ${getCookie('loginToken')}`,
Authorization: `Bearer ${loginToken}`,
},
});
return res.json();
};
const { data, mutate, isError, isLoading, isSuccess } = useMutation(postPet);
const handleRegisterButtonClick = async () => {
console.log(registerPetData);
if (!selectedImageFile || !selectedVideoFile || !registerPetData.isComplete)
return;
const formData = new FormData();
formData.append('profileVideo', selectedVideoFile);
formData.append('profileImage', selectedImageFile);
const { isComplete, ...restRegisterPetData } = registerPetData;
const registerPetDataWithPetPolygonProfileDto = {
...restRegisterPetData,
petPolygonProfileDto: {
...restRegisterPetData.petPolygonProfileDto,
},
};
formData.append(
'petInfo',
new Blob([JSON.stringify(registerPetDataWithPetPolygonProfileDto)], {
new Blob([JSON.stringify(restRegisterPetData)], {
type: 'application/json',
}),
);
Expand Down
20 changes: 10 additions & 10 deletions src/pages/register/StatusSelectGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,49 @@ const StatusSelectGroup = () => {
setIntelligenceOption(option);
setProfileStatus((prev) => ({
...prev,
polygonProfile: {
petPolygonProfileDto: {
...prev.petPolygonProfileDto,
intelligence: Number(option),
intelligence: option,
},
}));
break;
case 'affinity':
setAffinityOption(option);
setProfileStatus((prev) => ({
...prev,
polygonProfile: {
petPolygonProfileDto: {
...prev.petPolygonProfileDto,
affinity: Number(option),
affinity: option,
},
}));
break;
case 'athletic':
setAthleticOption(option);
setProfileStatus((prev) => ({
...prev,
polygonProfile: {
petPolygonProfileDto: {
...prev.petPolygonProfileDto,
athletic: Number(option),
athletic: option,
},
}));
break;
case 'adaptability':
setAdaptabilityOption(option);
setProfileStatus((prev) => ({
...prev,
polygonProfile: {
petPolygonProfileDto: {
...prev.petPolygonProfileDto,
adaptability: Number(option),
adaptability: option,
},
}));
break;
case 'activeness':
setActivenessOption(option);
setProfileStatus((prev) => ({
...prev,
polygonProfile: {
petPolygonProfileDto: {
...prev.petPolygonProfileDto,
activeness: Number(option),
activeness: option,
},
}));
break;
Expand Down

0 comments on commit 78c1531

Please sign in to comment.