Skip to content

Commit 17dfb87

Browse files
authored
Merge pull request #210 from prgrms-web-devcourse-final-project/chore/209-kakao-login
[chore] 카카오 로그인 로직 주석 해제
2 parents de60e76 + bdcdb91 commit 17dfb87

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/components/KaKaoRedirection.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
// import { getKakaoLogin } from '@/apis/auth';
1+
import { getKakaoLogin } from '@/apis/auth';
22
import Loading from '@/components/loading/Loading';
3-
// import { useAuthStore } from '@/store/authStore';
3+
import { useAuthStore } from '@/store/authStore';
44
import { useEffect } from 'react';
5-
// import { useNavigate } from 'react-router';
5+
import { useNavigate } from 'react-router';
66

77
function KaKaoRedirection() {
8-
// const navigate = useNavigate();
8+
const navigate = useNavigate();
99
const kakaoCode = new URL(window.location.href).searchParams.get('code');
10-
// const { setAccessToken } = useAuthStore();
10+
const { setAccessToken } = useAuthStore();
1111

12-
// const handleKaKaoLogin = async () => {
13-
// try {
14-
// console.log('kakaoCode', kakaoCode);
15-
// const { code, data } = await getKakaoLogin(kakaoCode as string);
16-
// if (code === 200) {
17-
// setAccessToken(data.accessToken);
18-
// navigate('/home');
19-
// } else {
20-
// throw new Error('로그인 에러');
21-
// }
22-
// } catch (error) {
23-
// console.error('로그인 에러가 발생했습니다.');
24-
// }
25-
// };
12+
const handleKaKaoLogin = async () => {
13+
try {
14+
console.log('kakaoCode', kakaoCode);
15+
const { code, data } = await getKakaoLogin(kakaoCode as string);
16+
if (code === 200) {
17+
setAccessToken(data.accessToken);
18+
navigate('/home');
19+
} else {
20+
throw new Error('로그인 에러');
21+
}
22+
} catch (error) {
23+
console.error('로그인 에러가 발생했습니다.');
24+
}
25+
};
2626

2727
useEffect(() => {
2828
if (kakaoCode) {
2929
console.log('🔴 kakaoCode', kakaoCode);
30-
// handleKaKaoLogin();
30+
handleKaKaoLogin();
3131
}
3232
}, []);
3333
return <Loading />;

0 commit comments

Comments
 (0)