From 52a15d8691f884610b334ad939e3ada65d13caec Mon Sep 17 00:00:00 2001 From: Chris-1010 <122332721@umail.ucc.ie> Date: Sun, 23 Feb 2025 23:08:58 +0000 Subject: [PATCH] UPDATE/FIX: Add loading to retrieve user details before routing users to credential-sensitive pages --- frontend/src/App.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 104c7ce..876d91f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -19,6 +19,7 @@ function App() { const [isLoggedIn, setIsLoggedIn] = useState(false); const [userId, setUserId] = useState(null); const [username, setUsername] = useState(null); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { fetch("/api/user/login_status") @@ -31,9 +32,16 @@ function App() { .catch((error) => { console.error("Error fetching login status:", error); setIsLoggedIn(false); + }) + .finally(() => { + setIsLoading(false); }); }, []); + if (isLoading) { + return
Loading...
; + } + return (