diff --git a/client/pages/Realms.tsx b/client/pages/Realms.tsx new file mode 100644 index 00000000..5f12c283 --- /dev/null +++ b/client/pages/Realms.tsx @@ -0,0 +1,72 @@ +import Layout from "@/components/Layout"; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { REALM_OPTIONS, RealmKey } from "@/components/settings/RealmSwitcher"; +import { useAuth } from "@/contexts/AuthContext"; +import { useMemo } from "react"; +import { Link } from "react-router-dom"; +import { cn } from "@/lib/utils"; + +export default function Realms() { + const { profile, roles } = useAuth(); + const lastRealm = (profile as any)?.user_type as RealmKey | undefined; + const canSeeStaff = useMemo( + () => roles.some((r) => ["owner", "admin", "founder", "staff", "employee"].includes(r.toLowerCase())), + [roles], + ); + const visible = useMemo( + () => REALM_OPTIONS.filter((o) => (o.id === "staff" ? canSeeStaff : true)), + [canSeeStaff], + ); + + return ( + +
+
+ Realms +

Choose your realm

+

Your dashboard adapts to the selected realm. Last used realm is highlighted.

+
+
+ {visible.map((realm, i) => { + const Icon = realm.icon; + const active = lastRealm === realm.id; + return ( + + +
+
+ +
+
+ {realm.title} + {realm.name} +
+
+
+ +

{realm.description}

+
+ {realm.highlights.slice(0, 3).map((h) => ( + {h} + ))} +
+
+ {/* Navigates to dashboard and sets realm via query param */} + +
+
+ {active && ( +
+ )} + + ); + })} +
+
+ + ); +}