Skip sign in when signed in
This commit is contained in:
38
client/src/components/SignedInStatusVerifier.tsx
Normal file
38
client/src/components/SignedInStatusVerifier.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { retrieveUserInformation } from "../security/users";
|
||||
import { CircularProgress } from "@nextui-org/react";
|
||||
|
||||
export default function SignedInStatusVerifier({
|
||||
children,
|
||||
}: {
|
||||
children: React.JSX.Element;
|
||||
}) {
|
||||
let navigate = useNavigate();
|
||||
let [isLoading, setIsLoading] = useState(true);
|
||||
useEffect(() => {
|
||||
retrieveUserInformation()
|
||||
.then((value) => {
|
||||
if (value) navigate("/springboard");
|
||||
})
|
||||
.catch(() => {
|
||||
setIsLoading(false);
|
||||
});
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
{!isLoading && <>{children}</>}
|
||||
{isLoading && (
|
||||
<div className="absolute inset-0 flex flex-col justify-center w-full h-full">
|
||||
<div className="flex flex-row justify-center w-full h-full">
|
||||
<CircularProgress
|
||||
aria-label="Trying to sign in..."
|
||||
label="Please wait..."
|
||||
size="lg"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,36 +1,39 @@
|
||||
import SignInModule from "../components/SignInModule";
|
||||
import DefaultLayout from "../layouts/default";
|
||||
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||
|
||||
export default function SignInPage() {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<div className="flex flex-col h-full">
|
||||
<div className="flex flex-row h-full">
|
||||
<div className="w-3/5 relative">
|
||||
<div className="absolute inset-0">
|
||||
<div className="w-full h-full relative">
|
||||
<img
|
||||
src="../assets/SigninScreenBG.png"
|
||||
alt="HDB flat"
|
||||
className="w-full h-full object-cover -z-10"
|
||||
/>
|
||||
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||
<p className="text-7xl font-semibold">Welcome back!</p>
|
||||
<p className="text-3xl">
|
||||
Good to have you here again. Tell us who you are, and
|
||||
we'll will let you in.
|
||||
</p>
|
||||
<SignedInStatusVerifier>
|
||||
<DefaultLayout>
|
||||
<div className="flex flex-col h-full">
|
||||
<div className="flex flex-row h-full">
|
||||
<div className="w-3/5 relative">
|
||||
<div className="absolute inset-0">
|
||||
<div className="w-full h-full relative">
|
||||
<img
|
||||
src="../assets/SigninScreenBG.png"
|
||||
alt="HDB flat"
|
||||
className="w-full h-full object-cover -z-10"
|
||||
/>
|
||||
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||
<p className="text-7xl font-semibold">Welcome back!</p>
|
||||
<p className="text-3xl">
|
||||
Good to have you here again. Tell us who you are, and
|
||||
we'll will let you in.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-2/5 p-8">
|
||||
<SignInModule />
|
||||
<div className="w-2/5 p-8">
|
||||
<SignInModule />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DefaultLayout>
|
||||
</DefaultLayout>
|
||||
</SignedInStatusVerifier>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
import SignUpModule from "../components/SignUpModule";
|
||||
import DefaultLayout from "../layouts/default";
|
||||
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||
|
||||
export default function SignUpPage() {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<div className="flex flex-col h-full">
|
||||
<div className="flex flex-row h-full">
|
||||
<div className="w-3/5 relative">
|
||||
<div className="absolute inset-0">
|
||||
<div className="w-full h-full relative">
|
||||
<img
|
||||
src="../assets/SignupScreenBG.png"
|
||||
alt="HDB flat"
|
||||
className="w-full h-full object-cover -z-10"
|
||||
/>
|
||||
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||
<p className="text-7xl font-semibold">Welcome!</p>
|
||||
<p className="text-3xl">
|
||||
Register a new account to access all of HDB Residence
|
||||
services.
|
||||
</p>
|
||||
<SignedInStatusVerifier>
|
||||
<DefaultLayout>
|
||||
<div className="flex flex-col h-full">
|
||||
<div className="flex flex-row h-full">
|
||||
<div className="w-3/5 relative">
|
||||
<div className="absolute inset-0">
|
||||
<div className="w-full h-full relative">
|
||||
<img
|
||||
src="../assets/SignupScreenBG.png"
|
||||
alt="HDB flat"
|
||||
className="w-full h-full object-cover -z-10"
|
||||
/>
|
||||
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||
<p className="text-7xl font-semibold">Welcome!</p>
|
||||
<p className="text-3xl">
|
||||
Register a new account to access all of HDB Residence
|
||||
services.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-2/5 p-8">
|
||||
<SignUpModule></SignUpModule>
|
||||
<div className="w-2/5 p-8">
|
||||
<SignUpModule></SignUpModule>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DefaultLayout>
|
||||
</DefaultLayout>
|
||||
</SignedInStatusVerifier>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user