diff --git a/client/src/components/Logins/GoogleSignin.tsx b/client/src/components/Logins/GoogleSignin.tsx index e49f5a46..88c9e51a 100644 --- a/client/src/components/Logins/GoogleSignin.tsx +++ b/client/src/components/Logins/GoogleSignin.tsx @@ -1,10 +1,24 @@ import React from 'react'; import { GoogleOAuthProvider, GoogleLogin, useGoogleOneTapLogin } from '@react-oauth/google'; +import { useDispatch } from 'react-redux'; +import { setLoginState } from '../../reducer/member/loginSlice'; const GoogleSignInComponent: React.FC = () => { + + const dispatch = useDispatch(); // Redux의 dispatch 함수를 사용하기 위해 가져옵니다. + // eslint-disable-next-line @typescript-eslint/no-explicit-any const handleSuccess = (credentialResponse: any) => { console.log(credentialResponse); + + const token = credentialResponse.token; // 실제 응답에서 토큰의 경로가 어떤지 확인하고 수정해야 합니다. + localStorage.setItem('authToken', token); // 토큰을 localStorage에 저장 + + // 로그인 성공 시 전역 상태를 업데이트합니다. + dispatch(setLoginState({ + memberId: credentialResponse.memberId, // memberId는 예시입니다. 실제 값에 맞게 수정해야 합니다. + isLoggedIn: 1, + })); }; const handleError = () => { diff --git a/client/src/page/MainPage.tsx b/client/src/page/MainPage.tsx index c1e70e78..5d6b34c8 100644 --- a/client/src/page/MainPage.tsx +++ b/client/src/page/MainPage.tsx @@ -16,11 +16,8 @@ import Holdings from "../components/watchlist/Holdings"; // Assuming you have a import CompareChartSection from "../components/CompareChartSection/Index"; import StockOrderSection from "../components/StockOrderSection/Index"; import Welcome from "../components/Signups/Welcome"; - import ProfileModal from "../components/Profile/profileModal"; - import { StateProps } from "../models/stateProps"; - import { TabContainerPage } from "./TabPages/TabContainerPage"; const MainPage = () => { diff --git a/client/src/reducer/member/loginSlice.ts b/client/src/reducer/member/loginSlice.ts index fd1fdf2f..558b0408 100644 --- a/client/src/reducer/member/loginSlice.ts +++ b/client/src/reducer/member/loginSlice.ts @@ -4,16 +4,16 @@ const loginSlice = createSlice({ name: 'login', initialState: { memberId: null, - isLoggedOut: 1 + isLoggedIn: 1 }, reducers: { setLoginState: (state, action) => { state.memberId = action.payload; - state.isLoggedOut = 0; + state.isLoggedIn = 1; }, setLogoutState: (state) => { state.memberId = null; - state.isLoggedOut = 1; + state.isLoggedIn = 0; }, updateMemberId: (state, action) => { state.memberId = action.payload;