Skip to content

Commit

Permalink
♻️ Refactor: 내 프로필 정보 api 추가 및 수정 성공 시 navigate 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-paik committed Nov 19, 2023
1 parent 3bbe3de commit 586e2ed
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/pages/ProfilePage/ProfileEditPage/ProfileEditPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ProfileEditPage = () => {
const navigate = useNavigate();
const [userInfo, setUserInfo] = useRecoilState(userInfoAtom);

const { data: myInfo, isLoading } = useQuery('getProfile', getMyInfo);
const { data: myInfo, isLoading} = useQuery('getProfile', getMyInfo);

const { mutate: accountname } = useMutation('accountnameValid', postAccountnameDuplicate, {
onSuccess: (res) => {
Expand All @@ -30,24 +30,23 @@ const ProfileEditPage = () => {
onError: (error) => {
console.log(error);
}
})
})

const { mutate: edit } = useMutation('edit', editProfile, {
onSuccess: (res) => {
if (res.status === 200) {
setUserInfo({
...userInfo,
account: res.user.accountname,
profileImg: res.user.image,
username: res.user.username,
intro: res.user.intro,
})
navigate(`/profile/${accountname}`);
} else {
setIsError(true);
}
account: res.user.accountname,
profileImg: res.user.image,
username: res.user.username,
intro: res.user.intro,
});
navigate(`/profile/${res.user.accountname}`);
},
onError: (error) => {
console.log(error);
}
})
});

if (isLoading) {
return <p>Loading...</p>;
Expand All @@ -66,7 +65,7 @@ const Container = styled.main`
margin: 0 auto;
`
const Title = styled.h1`
padding-top: 2.7rem;
padding-top: 3.2rem;
color: ${({theme}) => theme.colors.blackText};
font-size: ${({theme}) => theme.fontSize.xxlarge};
text-align: center;
Expand Down

0 comments on commit 586e2ed

Please sign in to comment.