From 0a8d3344c64e86a29e8ba6406f3b9061846103c3 Mon Sep 17 00:00:00 2001 From: zooby Date: Thu, 21 Sep 2023 01:26:14 +0900 Subject: [PATCH] fix: update api method --- src/apis/api/valorant.ts | 10 ++++++++++ src/pages/mypage/RsoCallback.tsx | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/apis/api/valorant.ts b/src/apis/api/valorant.ts index 7a3c92d..89a2004 100644 --- a/src/apis/api/valorant.ts +++ b/src/apis/api/valorant.ts @@ -66,3 +66,13 @@ export const connectRSO = async (rsoAccessCode: string) => { return { gameName, tagLine }; }; + +export const connectRSOMypage = async (rsoAccessCode: string) => { + const response = await defaultAxios.post('/api/valorant/user/mypage/sign', { + code: rsoAccessCode, + }); + + const { gameName, tagLine } = response.data; + + return { gameName, tagLine }; +}; diff --git a/src/pages/mypage/RsoCallback.tsx b/src/pages/mypage/RsoCallback.tsx index b7c88fe..487b8dc 100644 --- a/src/pages/mypage/RsoCallback.tsx +++ b/src/pages/mypage/RsoCallback.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useNavigate } from 'react-router-dom'; import { defaultAxios } from 'apis/utils'; -import { connectRSO } from 'apis/api/valorant'; +import { connectRSOMypage } from 'apis/api/valorant'; import { changeNickname } from 'apis/api/user'; import { snackbarActions } from 'store/snackbar-slice'; import Linear from 'components/loading/Linear'; @@ -11,10 +11,16 @@ const RsoCallback = () => { const params = new URL(document.URL).searchParams; const rsoAccessCode = params.get('code'); + if (!rsoAccessCode) { + navigate('/mypage'); + } + React.useEffect(() => { const doConnectRSO = async () => { try { - const { gameName, tagLine } = await connectRSO(rsoAccessCode as string); + const { gameName, tagLine } = await connectRSOMypage( + rsoAccessCode as string, + ); // TODO: load history 로 수정하기 await defaultAxios.get(`/api/valorant/user/${gameName}%23${tagLine}`);