-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: 로그인 시 이전 페이지로 리다이렉트 중 관련 에러 + 로그아웃 버튼 클릭 관련 에러 해결 (#527)
* refactor: getQueryString -> getRestaurantQueryString으로 네이밍 변경 * fix: 로그인 리다이렉트 시 query 구문 전달하지 않는 에러 해결(#526) * refactor: 로그인, 로그아웃 요청하는 useAuth 훅 구현 (#528) logout 로직을 useMutation을 활용하여 해결 * refactor: 로그인 버튼과 로그아웃 버튼에 useAuth 적용 (#528) * refactor: getRestaurantQueryString함수에 리팩터링 (#526) Changed: getRestaurantQueryString함수에 getQueryString사용 * refactor: isEqual 함수 제거 (#526)
- Loading branch information
Showing
12 changed files
with
91 additions
and
67 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export const SERVER_IMG_URL = 'https://www.celuveat.com/images-data/'; | ||
|
||
export const MSW_LOGIN_URL = 'https://d.api.celuveat.com/login/local?id=abc'; | ||
|
||
export const MSW_GET_OAUTH_CODE_URL = '/oauth/redirect/kakao?code=12312421'; |
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,39 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { getAccessToken, getLogout } from '~/api/user'; | ||
|
||
import usePathNameState from '~/hooks/store/usePathnameState'; | ||
|
||
const useAuth = () => { | ||
const navigator = useNavigate(); | ||
const path = usePathNameState(state => state.path); | ||
|
||
const doLoginMutation = useMutation({ | ||
mutationFn: getAccessToken, | ||
onSuccess: () => { | ||
navigator(path); | ||
}, | ||
onError: () => { | ||
navigator('/'); | ||
alert('서버 문제로 인해 로그인에 실패하였습니다.'); | ||
}, | ||
}); | ||
|
||
const doLogoutMutation = useMutation({ | ||
mutationFn: getLogout, | ||
onSuccess: () => { | ||
window.location.reload(); | ||
}, | ||
onError: () => { | ||
navigator('/'); | ||
alert('서버 문제로 인해 로그아웃에 실패하였습니다.'); | ||
}, | ||
}); | ||
|
||
return { | ||
doLoginMutation: doLoginMutation.mutate, | ||
doLogoutMutation: doLogoutMutation.mutate, | ||
}; | ||
}; | ||
|
||
export default useAuth; |
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