From b8682e0eaf0bd6b09300897324f59cfb25d8b04c Mon Sep 17 00:00:00 2001 From: zooby Date: Tue, 12 Sep 2023 16:10:14 +0900 Subject: [PATCH] feat : Save vlrt nickname (redux) --- src/pages/register/Games.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pages/register/Games.tsx b/src/pages/register/Games.tsx index 85802c1..8a2ad07 100644 --- a/src/pages/register/Games.tsx +++ b/src/pages/register/Games.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useNavigate } from 'react-router-dom'; -import { useSelector } from 'react-redux'; +import { useSelector, useDispatch } from 'react-redux'; // mui import { styled } from '@mui/system'; @@ -10,6 +10,8 @@ import MuiTypography from '@mui/material/Typography'; import { RootState } from 'store'; import { defaultAxios } from 'apis/utils'; +import { registerActions } from 'store/register-slice'; +import { GAME_ID } from 'types/games'; import InputLol from './InputLol'; import InputPubg from './InputPubg'; import InputOverwatch from './InputOverwatch'; @@ -17,6 +19,7 @@ import InputValorant from './InputValorant'; const Games = () => { const navigate = useNavigate(); + const dispatch = useDispatch(); const params = new URL(document.URL).searchParams; const rsoAccessCode = params.get('code'); @@ -27,6 +30,17 @@ const Games = () => { const response = await defaultAxios.post('/api/valorant/user/exist', { code: rsoAccessCode as string, }); + + if (response.data) { + const { gameName, tagLine } = response.data; + + dispatch( + registerActions.SET_GAMES_WITH_ID({ + id: 'valorant' as GAME_ID, + value: `${gameName}#${tagLine}`, + }), + ); + } }; if (rsoAccessCode) {