From 94a9c05842344e38fe279b6c6fa0636f76a953b9 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 21:28:49 +0000 Subject: [PATCH] Make /dashboard adapt to realm and accept ?realm= param cgen-7f688d6c275d4868b3b0bfedf5a8f6aa --- client/pages/Dashboard.tsx | 131 ++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 22 deletions(-) diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index f0187888..d68d730b 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -128,6 +128,35 @@ export default function Dashboard() { } }, [searchParams, activeTab]); + // Accept ?realm= to switch dashboards via Realms page + useEffect(() => { + const paramRealm = (searchParams.get("realm") || "").trim() as RealmKey; + const validRealms: RealmKey[] = [ + "game_developer", + "client", + "community_member", + "customer", + "staff", + ]; + const current = ((profile as any)?.user_type as RealmKey) ?? null; + if (paramRealm && validRealms.includes(paramRealm) && paramRealm !== current) { + (async () => { + try { + await updateProfile({ user_type: paramRealm } as any); + setUserRealm(paramRealm); + } catch {} + // remove query param after applying + const next = new URLSearchParams(searchParams.toString()); + next.delete("realm"); + setSearchParams(next, { replace: true }); + })(); + } else if (paramRealm) { + const next = new URLSearchParams(searchParams.toString()); + next.delete("realm"); + setSearchParams(next, { replace: true }); + } + }, [searchParams, profile?.user_type, updateProfile, setSearchParams]); + useEffect(() => { if (typeof window === "undefined" || !user) { return; @@ -633,6 +662,9 @@ export default function Dashboard() { ); } + // Determine active realm for dashboard personalization + const activeRealm: RealmKey = (userRealm || ((profile as any)?.user_type as RealmKey) || "community_member") as RealmKey; + return (
@@ -686,20 +718,19 @@ export default function Dashboard() {

- Welcome back,{" "} - {profile?.full_name || user.email?.split("@")[0]} + {activeRealm === "game_developer" && "Developer Dashboard"} + {activeRealm === "client" && "Client Dashboard"} + {activeRealm === "community_member" && "Community Dashboard"} + {activeRealm === "customer" && "Customer Dashboard"} + {activeRealm === "staff" && "Staff Dashboard"}

- {profile?.role || "Member"} • Level {profile?.level || 1} •{" "} - {streakLabel} 🔥 + Welcome back, {profile?.full_name || user.email?.split("@")[0]} • {streakLabel}

{longestStreak > 0 && (
- - Longest streak: {longestStreak}d + + Realm: {activeRealm.replace("_", " ")}
)} @@ -820,7 +851,7 @@ export default function Dashboard() { {/* Main Content */}
- {/* Stats Grid */} + {/* Stats Grid (adapts per realm by labels) */}
{statsDisplay.map((stat, index) => { const Icon = stat.icon; @@ -852,18 +883,74 @@ export default function Dashboard() { })}
- {/* Central Post Composer */} - - - Create a Post - - Share updates, images, or videos - - - - - - + {/* Realm spotlight */} + {activeRealm === "game_developer" && ( + + + Create a Post + Share updates, images, or videos + + + + + + )} + + {activeRealm === "community_member" && ( + + + Community actions + Post to the feed and explore trending topics + + + {}} /> +
+ + +
+
+
+ )} + + {activeRealm === "client" && ( + + + Project workspace + Kick off engagements and track delivery + + + + + + + + )} + + {activeRealm === "customer" && ( + + + Get started + Explore products and manage access + + + + + + + )} + + {activeRealm === "staff" && ( + + + Operations + Moderation and internal tools + + + + + + + )} {/* Settings Section */}