From e7a755a151d3d9944d5062f023077f82d326f445 Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Sun, 23 May 2021 15:36:27 +0200
Subject: [PATCH] Restore circular progress on page loading.

---
 src/components/RestrictedRoute/RestrictedRoute.tsx | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/components/RestrictedRoute/RestrictedRoute.tsx b/src/components/RestrictedRoute/RestrictedRoute.tsx
index 045f868..2f10632 100644
--- a/src/components/RestrictedRoute/RestrictedRoute.tsx
+++ b/src/components/RestrictedRoute/RestrictedRoute.tsx
@@ -24,11 +24,15 @@ export const RestrictedRoute = ({ Component, path }: Props): JSX.Element => {
   const [isLoading, setLoading] = useState<boolean>(false);
 
   useEffect(() => {
-    isAuthenticated().then((res) => setIsAuth(res));
-    console.log(isAuth);
-  }, [isAuth]);
+    isAuthenticated().then((res) => {
+      setIsAuth(res);
+      setLoading(true);
+    });
+  }, [isAuth, setLoading]);
 
-  return (
+  return !isLoading ? (
+    <CircularProgress />
+  ) : (
     <Route
       path={path}
       render={(props: RouteProps) =>
-- 
GitLab