From 5612797b3d9b2ecc95668306e7140635d6379205 Mon Sep 17 00:00:00 2001 From: Danielle Lindblom Date: Thu, 7 Nov 2024 11:12:06 -0700 Subject: [PATCH] fix: implement conditional rendering of page --- app/(main)/login/page.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/(main)/login/page.tsx b/app/(main)/login/page.tsx index dbc3e6e3..50714e2e 100644 --- a/app/(main)/login/page.tsx +++ b/app/(main)/login/page.tsx @@ -52,19 +52,15 @@ type LoginUserSchemaType = z.infer; */ const Login = (): React.JSX.Element => { const router = useRouter(); - const { login, isSignedIn, getUser } = useAuthContext(); + const { login, isSignedIn } = useAuthContext(); const [isLoading, setIsLoading] = useState(false); - const [checkAuth, setCheckAuth] = useState(true); useEffect(() => { if (isSignedIn === true) { router.push('/league/all'); } - if (isSignedIn === false) { - setCheckAuth(false); - } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isSignedIn, getUser]); + }, [isSignedIn]); const form = useForm({ resolver: zodResolver(LoginUserSchema), @@ -101,10 +97,10 @@ const Login = (): React.JSX.Element => { }; return ( -
- {checkAuth ? ( +
+ {isSignedIn === null ? ( - ) : ( + ) : (isSignedIn === false && <>