From 436dbc62667f6210d5aa8b1bbfa6c53626f9dd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20B=C3=B6ckmann?= Date: Thu, 4 Apr 2024 18:19:51 +0200 Subject: [PATCH] style: added loader to dashboard home --- src/app/dashboard/page.tsx | 97 +++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index 716ef76..f157c59 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -14,17 +14,22 @@ import { } from "@/components/ui/dropdown-menu"; import { type User } from "@/types"; import { extractNameInitials } from "@/lib/utils"; +import Image from "next/image"; function Dashboard() { const [user, setUser] = useState(); + const [loading, setLoading] = useState(true); useEffect(() => { const fetchUser = async () => { + setLoading(true); try { const accessToken = await getAccessToken(); setUser(await getUser(accessToken)); + setLoading(false); } catch (error) { console.error("Failed to fetch user", error); + setLoading(false); } }; fetchUser().catch(console.error); @@ -39,51 +44,59 @@ function Dashboard() { throw error; } }; - return ( -
-
-

Welcome back, {user?.name}

-
- - - - - - - -
-

{user?.name}

-

{user?.email}

-
-
- - Settings - - - Log out - -
-
-
-
- -
-

MeetMate Dashboard

-

Create your appointments in minutes

- + if (loading) + return ( +
+
+ {""}
+ ); + else + return ( +
+
+

Welcome back, {user?.name}

+
+ + + + + + + +
+

{user?.name}

+

{user?.email}

+
+
+ + Settings + + + Log out + +
+
+
+
-
+
+

MeetMate Dashboard

+

Create your appointments in minutes

+ +
-
-
- ); +
+ +
+
+ ); } export default Dashboard;