Skip to content

Commit

Permalink
💩 : #48 -replace로 수정, login 조건부 렌더링
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdl60 committed Nov 13, 2023
1 parent 6681bb6 commit 48b5016
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 37 deletions.
4 changes: 3 additions & 1 deletion src/app/(headerless)/login/hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default function useLogin() {
const { auth } = useAuth();
const router = useRouter();
useEffect(() => {
if (auth !== null) router.push('/home');
if (auth !== null) router.replace('/home');
}, [auth, router]);

return { isLogin: auth !== null };
}
74 changes: 39 additions & 35 deletions src/app/(headerless)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,48 @@ import useLogin from './hooks/useLogin';
import './index.scss';

export default function LoginPage() {
useLogin();
const { isLogin } = useLogin();
return (
<div className="wrapper">
<div className="login">
<Image
className="login__logo"
src="/this-year-ajaja-logo.svg"
width={260}
height={190}
alt="thisYearAjajaLogo"
/>
<div className="login__sentence color-origin-gray-300 font-size-2xl">
<span className="login__sentence--text">
올해의 신년 계획을 생성하고,
</span>
<span className="login__sentence--text">
주기적으로 리마인드 받아보세요!!
</span>
</div>
<div className="login__buttons">
<Link
className="login__buttons--kakaoLogin"
href={KAKAO_LOGIN_URL}
replace>
<>
{!isLogin && (
<div className="wrapper">
<div className="login">
<Image
src="/kakao_login_large_narrow.png"
width={230}
height={60}
alt="kakaoLogin"
className="login__logo"
src="/this-year-ajaja-logo.svg"
width={260}
height={190}
alt="thisYearAjajaLogo"
/>
</Link>
<Link
className="login__buttons--unAuth color-origin-gray-200"
href={UN_AUTH_URL}>
로그인 하지 않고 둘러보기
</Link>
<div className="login__sentence color-origin-gray-300 font-size-2xl">
<span className="login__sentence--text">
올해의 신년 계획을 생성하고,
</span>
<span className="login__sentence--text">
주기적으로 리마인드 받아보세요!!
</span>
</div>
<div className="login__buttons">
<Link
className="login__buttons--kakaoLogin"
href={KAKAO_LOGIN_URL}
replace>
<Image
src="/kakao_login_large_narrow.png"
width={230}
height={60}
alt="kakaoLogin"
/>
</Link>
<Link
className="login__buttons--unAuth color-origin-gray-200"
href={UN_AUTH_URL}>
로그인 하지 않고 둘러보기
</Link>
</div>
</div>
</div>
</div>
</div>
)}
</>
);
}
2 changes: 1 addition & 1 deletion src/app/(headerless)/oauth/hooks/useOauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function useOauth() {
setAuth(auth);
});

history.length >= 2 ? history.go(-2) : router.push('/home');
history.length >= 2 ? history.go(-2) : router.replace('/home');
})();
}, [setAuth, router]);
}

0 comments on commit 48b5016

Please sign in to comment.