From 97f181017df2ab4f1f6475905e8bd493039ec1ae Mon Sep 17 00:00:00 2001 From: choigeon96 Date: Tue, 13 Dec 2022 15:49:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=B1=84=ED=8C=85=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20color=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/commons/ChatButton/ChatButton.tsx | 2 +- client/src/hooks/useAuth.ts | 7 +++++-- client/src/pages/Login/Login.tsx | 3 ++- client/src/pages/SignUp/SignUp.tsx | 2 ++ client/src/styles/color.ts | 1 + 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/src/components/commons/ChatButton/ChatButton.tsx b/client/src/components/commons/ChatButton/ChatButton.tsx index bca06d5..80f9f4c 100644 --- a/client/src/components/commons/ChatButton/ChatButton.tsx +++ b/client/src/components/commons/ChatButton/ChatButton.tsx @@ -6,7 +6,7 @@ const ChatButton = () => { const { id } = useParams(); const navigate = useNavigate(); return ( - ); diff --git a/client/src/hooks/useAuth.ts b/client/src/hooks/useAuth.ts index eb13c41..db18fbf 100644 --- a/client/src/hooks/useAuth.ts +++ b/client/src/hooks/useAuth.ts @@ -3,14 +3,17 @@ import { useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { useRecoilValue } from "recoil"; -const useAuth = () => { +const useAuth = (withAuth = true) => { const userInfo = useRecoilValue(userState); const navigate = useNavigate(); useEffect(() => { - if (!userInfo.accessToken) { + if (withAuth && !userInfo.accessToken) { alert("로그인이 필요한 페이지입니다"); navigate("/login"); } + if (!withAuth && userInfo.accessToken) { + navigate(-1); + } }, []); return userInfo; }; diff --git a/client/src/pages/Login/Login.tsx b/client/src/pages/Login/Login.tsx index 929b346..46467d0 100644 --- a/client/src/pages/Login/Login.tsx +++ b/client/src/pages/Login/Login.tsx @@ -1,10 +1,11 @@ -import React from "react"; import Header from "#components/Header/Header"; import { LogoWrapper } from "./Login.styles"; import Navigator from "#components/Navigator/Navigator"; import LoginForm from "#components/LoginForm/LoginForm"; +import useAuth from "#hooks/useAuth"; const Login = () => { + useAuth(false); return ( <>
diff --git a/client/src/pages/SignUp/SignUp.tsx b/client/src/pages/SignUp/SignUp.tsx index 61e5421..8199a6a 100644 --- a/client/src/pages/SignUp/SignUp.tsx +++ b/client/src/pages/SignUp/SignUp.tsx @@ -3,8 +3,10 @@ import { Logo } from "./SignUp.styles"; import SignUpForm from "#components/SignUpForm/SignUpForm"; import Navigator from "#components/Navigator/Navigator"; +import useAuth from "#hooks/useAuth"; const SignUp = () => { + useAuth(false); return ( <>
diff --git a/client/src/styles/color.ts b/client/src/styles/color.ts index a923278..1db6edd 100644 --- a/client/src/styles/color.ts +++ b/client/src/styles/color.ts @@ -7,4 +7,5 @@ export enum COLOR { BABY_BLUE = "#ACB7C7", ORANGE = "#FFB800", F1F4F7 = "#F1F4F7", + CHAT_BUTTON = "#4A668B", }