import { FormLabel } from "@repo/rdx-ui/components/form-label"; import type { SelectAction } from "@repo/rdx-ui/components/select-with-action"; import { SelectWithAction } from "@repo/rdx-ui/components/select-with-action"; import { SwitchField } from "@repo/rdx-ui/components/switch-field"; import { Input } from "@repo/shadcn-ui/components/input"; import { Textarea } from "@repo/shadcn-ui/components/textarea"; import type { UseFormReturn } from "react-hook-form"; import { useTranslation } from "react-i18next"; import type { AccessField, AccessFormValues } from "../helpers"; import type { Option } from "../types"; import { PermissionsControl } from "./permissions-control"; export function AccessFieldControl({ field, id, form, value, options, disabled, onSelected, onCreate, createDisabled = false, createLabel, }: { field: AccessField; id: string; form: UseFormReturn; value: string | boolean | string[] | undefined; options: readonly Option[]; disabled: boolean; onSelected: (value: string) => void; onCreate?: (() => void) | undefined; createDisabled?: boolean; createLabel?: string | undefined; }) { const { t } = useTranslation("access"); if (field.type === "boolean") { return ( form.setValue(field.key, checked)} /> ); } if (field.type === "permissions") { return ( ); } return (
{t(field.key)} {field.type === "note" ? (