Skip to content

Commit

Permalink
Merge pull request #76 from Teammanagers/develop
Browse files Browse the repository at this point in the history
이슈 수정
  • Loading branch information
Low-ProFiles authored Aug 23, 2024
2 parents 49c4512 + 373adb3 commit f153193
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
22 changes: 1 addition & 21 deletions src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,24 @@ import LogoImage from '@assets/login/project-logo.svg';
import KakaoLogo from '@assets/login/kakao-logo.svg';
import NaverLogo from '@assets/login/naver-logo.svg';
import GoogleLogo from '@assets/login/google-logo.svg';
import { useEffect, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

const Login = () => {
const navigate = useNavigate();
const location = useLocation();
const [isRouteByEvent, setIsRouteByEvent] = useState<boolean>(false);
const handleKakaoButtonClick = () => {
window.location.href =
'https://dev.teammanagers.kr/oauth2/authorization/kakao';
setIsRouteByEvent(true);
};

const handleNaverButtonClick = () => {
window.location.href =
'https://dev.teammanagers.kr/oauth2/authorization/naver';
setIsRouteByEvent(true);
true;
};

const handleGoogleButtonClick = () => {
window.location.href =
'https://dev.teammanagers.kr/oauth2/authorization/google';
setIsRouteByEvent(true);
};

useEffect(() => {
const token = localStorage.getItem('accessToken');
const isNewUser = !!localStorage.getItem('isNewUser');

if (token && !!isNewUser) {
navigate('/signup');
}

if (token && !isNewUser) {
navigate('/team');
}
}, [isRouteByEvent, window.location.href]);

return (
<OnBoardingTextDiv>
<LogoImage />
Expand Down
16 changes: 15 additions & 1 deletion src/pages/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import LogoFadeIn from '@components/login/LogoFadeIn';
import { useLogoFadeIn } from '@hooks/useLogoFadeIn';
import styled from 'styled-components';
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';

const Wrapper = styled.div`
height: 100vh;
Expand All @@ -13,6 +13,7 @@ const Wrapper = styled.div`

export const LoginPage = () => {
const location = useLocation();
const navigate = useNavigate();
const isLogoFadeInActivate = useLogoFadeIn(3000);

useEffect(() => {
Expand All @@ -30,6 +31,19 @@ export const LoginPage = () => {
localStorage.setItem('isNewUser', isNewUser);
}, [location]);

useEffect(() => {
const token = localStorage.getItem('accessToken');
const isNewUser = !!localStorage.getItem('isNewUser');

if (token && !!isNewUser) {
navigate('/signup');
}

if (token && !isNewUser) {
navigate('/team');
}
}, [location]);

return (
<Wrapper>
{isLogoFadeInActivate ? <LogoFadeIn /> : <OnBoarding type="signin" />}
Expand Down

0 comments on commit f153193

Please sign in to comment.