diff --git a/app/components/InputMemberPermissionSelect.tsx b/app/components/InputMemberPermissionSelect.tsx index 5108671102..20a95b7a4d 100644 --- a/app/components/InputMemberPermissionSelect.tsx +++ b/app/components/InputMemberPermissionSelect.tsx @@ -2,37 +2,49 @@ import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; import { s } from "@shared/styles"; -import InputSelect, { Props as SelectProps } from "~/components/InputSelect"; +import { InputSelectNew, Option } from "~/components/InputSelectNew"; import { EmptySelectValue, Permission } from "~/types"; +type Props = Pick< + React.ComponentProps, + "value" | "onChange" | "disabled" | "className" +>; + export default function InputMemberPermissionSelect( - props: Partial & { permissions: Permission[] } + props: Props & { permissions: Permission[] } ) { const { value, onChange, ...rest } = props; const { t } = useTranslation(); + const options = React.useMemo( + () => + props.permissions.reduce((acc, permission) => { + if (permission.divider) { + acc.push({ type: "separator" }); + } + acc.push({ + ...permission, + type: "item", + }); + return acc; + }, [] as Option[]), + [props.permissions] + ); + return (