From fe5e7a4442ac177ddd7d69afa7039c1a9ab9b6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=89=E1=85=A5=E1=86=BC?= =?UTF-8?q?=E1=84=92=E1=85=B1?= Date: Mon, 12 Feb 2024 22:40:18 +0900 Subject: [PATCH] =?UTF-8?q?feature-059:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=9B=84=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/social-account.ts | 5 ++++- src/pages/SocialAccountPage.tsx | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/apis/social-account.ts b/src/apis/social-account.ts index 84670be..1159a81 100644 --- a/src/apis/social-account.ts +++ b/src/apis/social-account.ts @@ -1,5 +1,8 @@ +import { APIResponse } from '@/models/config/axios'; +import { LoginResponse } from '@/models/user'; + import axios from './config/instance'; export const kakaoLoginAPI = (code: string) => { - return axios.get(`/kakao-login?code=${code}`); + return axios.get>(`/kakao-login?code=${code}`); }; diff --git a/src/pages/SocialAccountPage.tsx b/src/pages/SocialAccountPage.tsx index 49e8293..e8014a6 100644 --- a/src/pages/SocialAccountPage.tsx +++ b/src/pages/SocialAccountPage.tsx @@ -1,15 +1,22 @@ import { useEffect } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; +import { useSetRecoilState } from 'recoil'; import { kakaoLoginAPI } from '@/apis/social-account'; +import { userTokenState } from '@/stores/user'; + const SocialAccountPage = () => { const navigate = useNavigate(); const { search } = useLocation(); + const setUserToken = useSetRecoilState(userTokenState); const callAPI = async (code: string) => { try { - console.log(await kakaoLoginAPI(code)); + const { token } = (await kakaoLoginAPI(code)).data.result; + + setUserToken(token); + navigate('/'); } catch (e) { console.error(e); navigate('/sign-in');