Gate staff realm visibility based on roles and use visibleOptions
cgen-67548eb06dd54c06b42c93ff89308125
This commit is contained in:
parent
318870ffd9
commit
7f322ba8f0
1 changed files with 9 additions and 0 deletions
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Reference in a new issue