From 74c5c6fcda4046c04160196c1156f2bbcffc6c75 Mon Sep 17 00:00:00 2001 From: JZU0 Date: Wed, 20 Dec 2023 14:53:50 +0900 Subject: [PATCH] [#4] feat : add google login --- src/components/LoginModal/index.jsx | 10 ++++++- src/pages/ResultLoading/index.jsx | 43 +++++++++++++++++++---------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/components/LoginModal/index.jsx b/src/components/LoginModal/index.jsx index 46a1489..d725152 100644 --- a/src/components/LoginModal/index.jsx +++ b/src/components/LoginModal/index.jsx @@ -19,13 +19,21 @@ const LoginModal = () => { navigate("/test/0"); }; + const handleGoogleLogin = () => { + window.location.href = `https://accounts.google.com/o/oauth2/v2/auth? + client_id=${process.env.REACT_APP_GOOGLE_AUTH_CLIENT_ID} + &redirect_uri=${process.env.REACT_APP_GOOGLE_AUTH_REDIRECT_URI} + &response_type=code + &scope=email profile`; + }; + const handleKakaoLogin = () => { window.location.href = kakaoURL; }; return ( - + google  Google 계정으로 로그인 diff --git a/src/pages/ResultLoading/index.jsx b/src/pages/ResultLoading/index.jsx index ac2116d..53fa8b9 100644 --- a/src/pages/ResultLoading/index.jsx +++ b/src/pages/ResultLoading/index.jsx @@ -1,6 +1,6 @@ import React, { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; import { useRecoilValue } from "recoil"; -import { axiosInstance } from "../../apis"; import { testState } from "../../store/atoms"; import { TestHeader } from "../../components"; import { @@ -18,21 +18,36 @@ const TestPage = () => { const testStateValue = useRecoilValue(testState); const values = `${testStateValue.T}${testStateValue.F}${testStateValue.E}${testStateValue.I}${testStateValue.X}${testStateValue.O}`; console.log(values); - - const getResult = async () => { - try { - const response = await axiosInstance.get( - `/api/v1/test-result?result=${values}`, - ); - console.log(response); - } catch (err) { - console.error(err); - } - }; + const navigate = useNavigate(); useEffect(() => { - getResult(); - }, []); + const routeMap = { + 303030: "/one", + 212121: "/one", + "031203": "/two", + 120312: "/two", + "030330": "/three", + 121221: "/three", + "033030": "/four", + 122121: "/four", + 301203: "/five", + 210312: "/five", + 300330: "/six", + 211221: "/six", + "032103": "/seven", + 123012: "/seven", + 302103: "/eight", + 213012: "/eight", + }; + + // Get the route based on the values + const route = routeMap[values]; + + // Redirect to the appropriate page after 2 seconds + setTimeout(() => { + navigate(route); + }, 2000); + }, [navigate, values]); return ( <>