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 && ( +
- Welcome back!
-- Good to have you here again. Tell us who you are, and - we'll will let you in. -
+
+ Welcome back!
++ Good to have you here again. Tell us who you are, and + we'll will let you in. +
+
- Welcome!
-- Register a new account to access all of HDB Residence - services. -
+
+ Welcome!
++ Register a new account to access all of HDB Residence + services. +
+