From 7f322ba8f0ef9bc185e68ba3ef0f141a3c68affa Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 05:20:10 +0000 Subject: [PATCH] Gate staff realm visibility based on roles and use visibleOptions cgen-67548eb06dd54c06b42c93ff89308125 --- client/components/settings/RealmSwitcher.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/components/settings/RealmSwitcher.tsx b/client/components/settings/RealmSwitcher.tsx index bfb42b37..a799271c 100644 --- a/client/components/settings/RealmSwitcher.tsx +++ b/client/components/settings/RealmSwitcher.tsx @@ -159,6 +159,15 @@ const RealmSwitcher = memo(function RealmSwitcher({ onSave, saving, }: RealmSwitcherProps) { + const { roles } = useAuth(); + const canSeeStaff = useMemo( + () => roles.some((r) => ["owner", "admin", "founder", "staff", "employee"].includes(r.toLowerCase())), + [roles], + ); + const visibleOptions = useMemo( + () => REALM_OPTIONS.filter((o) => (o.id === "staff" ? canSeeStaff : true)), + [canSeeStaff], + ); return (