Skip to content

Commit

Permalink
fix: update api method
Browse files Browse the repository at this point in the history
  • Loading branch information
PMtHk committed Sep 20, 2023
1 parent 614e93b commit 0a8d334
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/apis/api/valorant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};
10 changes: 8 additions & 2 deletions src/pages/mypage/RsoCallback.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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}`);
Expand Down

0 comments on commit 0a8d334

Please sign in to comment.