diff --git a/src/components/Login/index.tsx b/src/components/Login/index.tsx index 9842e2a3..128be7d5 100644 --- a/src/components/Login/index.tsx +++ b/src/components/Login/index.tsx @@ -1,7 +1,7 @@ import useLogin from '../../hooks/queries/member/useLogin'; const Login = () => { - useLogin(); + useLogin({ pageName: 'Start' }); return
로그인 중입니다....
; }; diff --git a/src/hooks/queries/member/useLogin.tsx b/src/hooks/queries/member/useLogin.tsx index bbeecb37..28d9f6d5 100644 --- a/src/hooks/queries/member/useLogin.tsx +++ b/src/hooks/queries/member/useLogin.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; import { authInstance } from '../../../apis/client'; -// import { useNavigate } from 'react-router'; +import { useNavigate } from 'react-router'; interface LoginResponseType extends Response { data: { @@ -19,8 +19,12 @@ interface LoginResponseType extends Response { }; } -const useLogin = () => { - // const navigate = useNavigate(); +interface useLoginProps { + pageName?: string; +} + +const useLogin = ({ pageName }: useLoginProps) => { + const navigate = useNavigate(); const code = new URL(window.location.href).searchParams.get('code'); const fetchAuth = (code: string): Promise => @@ -42,8 +46,9 @@ const useLogin = () => { console.log(data); console.log(localStorage.getItem('EXIT_LOGIN_TOKEN')); console.log(JWT); - - // navigate('/'); + if (pageName === 'Start') { + navigate('/'); + } } console.log(data);