login.tsx: Faster redirect from login to dashboard.

This commit is contained in:
Neeraj138
2023-02-01 18:42:03 +05:30
parent 71cf54c28b
commit 52697dea97

View File

@@ -22,6 +22,7 @@ export default function Login() {
const [password, setPassword] = useState('');
const [errorLogin, setErrorLogin] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [isAlreadyLoggedIn, setIsAlreadyLoggedIn] = useState(false);
const router = useRouter();
const { t } = useTranslation();
const lang = router.locale ?? 'en';
@@ -44,6 +45,7 @@ export default function Login() {
}
};
if (isLoggedIn()) {
setIsAlreadyLoggedIn(true);
redirectToDashboard();
}
}, []);
@@ -64,6 +66,10 @@ export default function Login() {
});
};
if (isAlreadyLoggedIn) {
return null
}
return (
<div className="bg-bunker-800 h-screen flex flex-col justify-start px-6">
<Head>