import { Checkbox } from "@repo/shadcn-ui/components/checkbox"; import { Input } from "@repo/shadcn-ui/components/input"; import { Label } from "@repo/shadcn-ui/components/label"; import type { SelectAction } from "@repo/shadcn-ui/components/select-with-action"; import { SelectWithAction } from "@repo/shadcn-ui/components/select-with-action"; import { Textarea } from "@repo/shadcn-ui/components/textarea"; import type { UseFormReturn } from "react-hook-form"; import { useTranslation } from "react-i18next"; import type { AccessField } from "./access-fields"; import type { AccessFormValues } from "./access-form-values"; type Option = { value: string; label: string }; 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 === true)} />
); } if (field.type === "permissions") { return ( ); } return (
{field.type === "note" ? (