-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve conflicts by merging dev to feat&refactor/144-map
- Loading branch information
Showing
45 changed files
with
879 additions
and
480 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useMutation } from 'react-query'; | ||
import instance from '../instance'; | ||
import { BaseResponse } from '../../types/BaseResponse'; | ||
import { LoginSuccess } from '../../types/auth/login'; | ||
import { ResponseCode } from '../../types/enum/ResponseCode'; | ||
import useRegisterStore from '../../stores/registerStore'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const useProfileUpdateMutation = (prevUrl: string) => { | ||
const { setLogIn, setIsIdDuplicate } = useRegisterStore(); | ||
const navigate = useNavigate(); | ||
|
||
const mutation = useMutation({ | ||
mutationFn: async (data: FormData) => { | ||
return await instance.patch<BaseResponse<LoginSuccess>>( | ||
`/user`, | ||
data, | ||
{ | ||
headers: { 'Content-Type': 'multipart/form-data' }, | ||
}, | ||
); | ||
}, | ||
onSuccess: (response) => { | ||
const responseData = response.data; | ||
|
||
if (responseData.code === ResponseCode.SUCCESS) { | ||
console.log('프로필 업데이트 성공!'); | ||
|
||
const profileId = responseData.result.profileId; | ||
const imgUrl = responseData.result.imgUrl; | ||
const accessToken = responseData.result.accessToken; | ||
setLogIn(profileId, imgUrl, accessToken); | ||
|
||
instance.defaults.headers.common['Authorization'] = | ||
`Bearer ${accessToken}`; // 로그인된 유저에 대하여 모든 API 호출에 accessToken 포함시키는 코드 | ||
|
||
navigate(prevUrl); | ||
return; | ||
} | ||
if (responseData.code === ResponseCode.ALREADY_EXIST_PROFILE_ID) { | ||
// 중복된 profileId인 경우 | ||
console.log('사용 중인 아이디'); | ||
setIsIdDuplicate(true); | ||
navigate(`${prevUrl + '?authState=signup'}`); | ||
return; | ||
} else { | ||
// 프로필 업데이트 오류 | ||
console.log('프로필 업데이트 실패'); | ||
navigate(`${prevUrl === '/' ? prevUrl : prevUrl + '?authState=login'}`); | ||
return; | ||
} | ||
}, | ||
onError: () => { | ||
console.log('프로필 업데이트 실패'); | ||
navigate(prevUrl); | ||
}, | ||
}); | ||
|
||
return mutation; | ||
}; | ||
|
||
export default useProfileUpdateMutation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
display: flex; | ||
z-index: 10; | ||
width: 72px; | ||
overflow: hidden; | ||
} | ||
|
||
.LeftSideBar { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.