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 && (
)} ); })}
); }