mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-22 16:55:44 +00:00
♻️ only select one role in CE and if user is non paying
This commit is contained in:
@@ -5,6 +5,8 @@ import { useDebounce } from "use-debounce";
|
|||||||
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { MultiSelectTagInput } from "./multi-select/multi-select-tag-input";
|
import { MultiSelectTagInput } from "./multi-select/multi-select-tag-input";
|
||||||
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
|
import { TierFeature, tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
|
||||||
export type SelectedRole = { id: string; text: string };
|
export type SelectedRole = { id: string; text: string };
|
||||||
|
|
||||||
@@ -27,6 +29,8 @@ export function RolesSelector({
|
|||||||
mapRolesByName,
|
mapRolesByName,
|
||||||
buttonText
|
buttonText
|
||||||
}: RolesSelectorProps) {
|
}: RolesSelectorProps) {
|
||||||
|
const { isPaidUser } = usePaidStatus();
|
||||||
|
const canSelectMultipleUsers = isPaidUser(tierMatrix.fullRbac);
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const [roleSearchQuery, setRoleSearchQuery] = useState("");
|
const [roleSearchQuery, setRoleSearchQuery] = useState("");
|
||||||
|
|
||||||
@@ -74,7 +78,13 @@ export function RolesSelector({
|
|||||||
onSearch={setRoleSearchQuery}
|
onSearch={setRoleSearchQuery}
|
||||||
options={rolesShown}
|
options={rolesShown}
|
||||||
value={selectedRoles}
|
value={selectedRoles}
|
||||||
onChange={onSelectRoles}
|
onChange={(newRoles) => {
|
||||||
|
let roles = canSelectMultipleUsers
|
||||||
|
? [...newRoles]
|
||||||
|
: [newRoles[0]];
|
||||||
|
|
||||||
|
onSelectRoles(roles);
|
||||||
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user