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", }