-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* style: 가입 페이지 클래스 네임 공백 제거 * feat: 카카오 로그인 페이지로 하이퍼링크 기능 작성 * chore: suspensive 라이브러리 업데이트 * test: 세연님과 테스트 * feat: 로그인 모킹 API 작성 * feat: 카카오 로그인 검증 후 리다이렉션 기능 작성 * feat: 로그인 검증 API를 POST로 변경 * fix: 에러 메시지 값 없을 경우 핸들링 * remove: authOptions 제거 * feat: URI 변동사항 적용
- Loading branch information
1 parent
862f5c9
commit 9c0a51a
Showing
9 changed files
with
132 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
VITE_BACKEND_API_ENDPOINT= # 백엔드 API 주소 | ||
VITE_BACKEND_API_ENDPOINT= # 백엔드 API 주소. ex) https://something.com | ||
VITE_LOCALHOST= # 로컬 개발서버 주소. ex) http://localhost:1111 | ||
VITE_DEPLOY_ENDPOINT= # 리액트 앱 배포 주소. ex) https://something.com | ||
VITE_KAKAO_LOGIN_CLIENT_ID= # 카카오 로그인 연동에 필요한 Client ID. |
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,16 @@ | ||
import { baseInstance } from '../instance'; | ||
|
||
const memberAPI = { | ||
postMemberKakaoAuth: async (params: { code: string }) => { | ||
const { code } = params; | ||
|
||
return await baseInstance.post<{ signUp: boolean; memberId: number }>( | ||
`/members/login/kakao/oauth`, | ||
{ | ||
code | ||
} | ||
); | ||
} | ||
}; | ||
|
||
export default memberAPI; |
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,35 @@ | ||
import { http, HttpResponse, delay } from 'msw'; | ||
import { baseURL } from '../baseURL'; | ||
|
||
const membersHandlers = [ | ||
http.post(baseURL('/members/login/kakao/oauth'), async () => { | ||
await delay(1000); | ||
|
||
const status: number = 200; | ||
let response = {}; | ||
const headers = new Headers(); | ||
|
||
switch (status) { | ||
case 200: | ||
response = { signUp: false, memberId: 5 }; | ||
headers.set('Set-Cookie', 'accessToken=MockedToken;'); | ||
headers.append('Set-Cookie', 'refreshToken=MockedToken;'); | ||
break; | ||
case 201: | ||
response = { signUp: true, memberId: 5 }; | ||
headers.set('Set-Cookie', 'accessToken=MockedToken;'); | ||
headers.append('Set-Cookie', 'refreshToken=MockedToken;'); | ||
break; | ||
case 404: | ||
response = { message: '존재하지 않는 유저입니다.' }; | ||
break; | ||
} | ||
|
||
return HttpResponse.json(response, { | ||
status, | ||
headers | ||
}); | ||
}) | ||
]; | ||
|
||
export default membersHandlers; |
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,42 @@ | ||
import { useEffect } from 'react'; | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import memberAPI from '@/core/api/functions/memberAPI'; | ||
import { useMoveRoute } from '@/core/hooks'; | ||
import { LoadingSpinner } from '@/shared/LoadingSpinner'; | ||
|
||
const JoinKakaoPage = () => { | ||
const [searchParams] = useSearchParams(); | ||
const code = searchParams.get('code'); | ||
const moveTo = useMoveRoute(); | ||
|
||
const { mutate, isPending, isError, error } = useMutation({ | ||
mutationFn: memberAPI.postMemberKakaoAuth | ||
}); | ||
|
||
useEffect(() => { | ||
mutate( | ||
{ code: code ?? '' }, | ||
{ | ||
onSuccess: ({ signUp }) => { | ||
moveTo(signUp ? 'guide' : 'start'); | ||
} | ||
} | ||
); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex h-full items-center justify-center"> | ||
{isPending && ( | ||
<LoadingSpinner | ||
colorStyle="text-light-point dark:text-dark-point" | ||
size="7xl" | ||
/> | ||
)} | ||
{(isError && error.response?.data?.message) ?? | ||
'로그인 중에 문제가 발생했어요.'} | ||
</div> | ||
); | ||
}; | ||
|
||
export default JoinKakaoPage; |
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