diff --git a/client/src/components/SignedInStatusVerifier.tsx b/client/src/components/SignedInStatusVerifier.tsx new file mode 100644 index 0000000..052b3b2 --- /dev/null +++ b/client/src/components/SignedInStatusVerifier.tsx @@ -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 && ( +
+
+ +
+
+ )} + + ); +} diff --git a/client/src/pages/SignInPage.tsx b/client/src/pages/SignInPage.tsx index c6120e1..1203788 100644 --- a/client/src/pages/SignInPage.tsx +++ b/client/src/pages/SignInPage.tsx @@ -1,36 +1,39 @@ import SignInModule from "../components/SignInModule"; import DefaultLayout from "../layouts/default"; +import SignedInStatusVerifier from "../components/SignedInStatusVerifier"; export default function SignInPage() { return ( - -
-
-
-
-
- HDB flat -
-
-

Welcome back!

-

- Good to have you here again. Tell us who you are, and - we'll will let you in. -

+ + +
+
+
+
+
+ HDB flat +
+
+

Welcome back!

+

+ Good to have you here again. Tell us who you are, and + we'll will let you in. +

+
-
-
- +
+ +
-
- + + ); } diff --git a/client/src/pages/SignUpPage.tsx b/client/src/pages/SignUpPage.tsx index de06468..c63d308 100644 --- a/client/src/pages/SignUpPage.tsx +++ b/client/src/pages/SignUpPage.tsx @@ -1,36 +1,39 @@ import SignUpModule from "../components/SignUpModule"; import DefaultLayout from "../layouts/default"; +import SignedInStatusVerifier from "../components/SignedInStatusVerifier"; export default function SignUpPage() { return ( - -
-
-
-
-
- HDB flat -
-
-

Welcome!

-

- Register a new account to access all of HDB Residence - services. -

+ + +
+
+
+
+
+ HDB flat +
+
+

Welcome!

+

+ Register a new account to access all of HDB Residence + services. +

+
-
-
- +
+ +
-
- + + ); }