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 SignInModule from "../components/SignInModule";
|
||||||
import DefaultLayout from "../layouts/default";
|
import DefaultLayout from "../layouts/default";
|
||||||
|
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||||
|
|
||||||
export default function SignInPage() {
|
export default function SignInPage() {
|
||||||
return (
|
return (
|
||||||
<DefaultLayout>
|
<SignedInStatusVerifier>
|
||||||
<div className="flex flex-col h-full">
|
<DefaultLayout>
|
||||||
<div className="flex flex-row h-full">
|
<div className="flex flex-col h-full">
|
||||||
<div className="w-3/5 relative">
|
<div className="flex flex-row h-full">
|
||||||
<div className="absolute inset-0">
|
<div className="w-3/5 relative">
|
||||||
<div className="w-full h-full relative">
|
<div className="absolute inset-0">
|
||||||
<img
|
<div className="w-full h-full relative">
|
||||||
src="../assets/SigninScreenBG.png"
|
<img
|
||||||
alt="HDB flat"
|
src="../assets/SigninScreenBG.png"
|
||||||
className="w-full h-full object-cover -z-10"
|
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">
|
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||||
<p className="text-7xl font-semibold">Welcome back!</p>
|
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||||
<p className="text-3xl">
|
<p className="text-7xl font-semibold">Welcome back!</p>
|
||||||
Good to have you here again. Tell us who you are, and
|
<p className="text-3xl">
|
||||||
we'll will let you in.
|
Good to have you here again. Tell us who you are, and
|
||||||
</p>
|
we'll will let you in.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className="w-2/5 p-8">
|
||||||
<div className="w-2/5 p-8">
|
<SignInModule />
|
||||||
<SignInModule />
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</DefaultLayout>
|
||||||
</DefaultLayout>
|
</SignedInStatusVerifier>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,39 @@
|
|||||||
import SignUpModule from "../components/SignUpModule";
|
import SignUpModule from "../components/SignUpModule";
|
||||||
import DefaultLayout from "../layouts/default";
|
import DefaultLayout from "../layouts/default";
|
||||||
|
import SignedInStatusVerifier from "../components/SignedInStatusVerifier";
|
||||||
|
|
||||||
export default function SignUpPage() {
|
export default function SignUpPage() {
|
||||||
return (
|
return (
|
||||||
<DefaultLayout>
|
<SignedInStatusVerifier>
|
||||||
<div className="flex flex-col h-full">
|
<DefaultLayout>
|
||||||
<div className="flex flex-row h-full">
|
<div className="flex flex-col h-full">
|
||||||
<div className="w-3/5 relative">
|
<div className="flex flex-row h-full">
|
||||||
<div className="absolute inset-0">
|
<div className="w-3/5 relative">
|
||||||
<div className="w-full h-full relative">
|
<div className="absolute inset-0">
|
||||||
<img
|
<div className="w-full h-full relative">
|
||||||
src="../assets/SignupScreenBG.png"
|
<img
|
||||||
alt="HDB flat"
|
src="../assets/SignupScreenBG.png"
|
||||||
className="w-full h-full object-cover -z-10"
|
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">
|
<div className="absolute inset-0 z-10 flex flex-col justify-center">
|
||||||
<p className="text-7xl font-semibold">Welcome!</p>
|
<div className="w-full text-right text-white flex flex-col gap-6 p-16">
|
||||||
<p className="text-3xl">
|
<p className="text-7xl font-semibold">Welcome!</p>
|
||||||
Register a new account to access all of HDB Residence
|
<p className="text-3xl">
|
||||||
services.
|
Register a new account to access all of HDB Residence
|
||||||
</p>
|
services.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className="w-2/5 p-8">
|
||||||
<div className="w-2/5 p-8">
|
<SignUpModule></SignUpModule>
|
||||||
<SignUpModule></SignUpModule>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</DefaultLayout>
|
||||||
</DefaultLayout>
|
</SignedInStatusVerifier>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user