Gate staff realm visibility based on roles and use visibleOptions

cgen-67548eb06dd54c06b42c93ff89308125
This commit is contained in:
Builder.io 2025-10-18 05:20:10 +00:00
parent 318870ffd9
commit 7f322ba8f0

View file

@ -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 (
<div className="space-y-6">
<div className="space-y-2">