import { Switch } from "@patternfly/react-core"; import { Controller, useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { FieldProps, FormGroupField } from "./FormGroupField"; type FieldType = "boolean" | "string"; type SwitchFieldProps = FieldProps & { fieldType?: FieldType; }; export const SwitchField = ({ label, field, fieldType = "string", isReadOnly = false, }: SwitchFieldProps) => { const { t } = useTranslation(); const { control } = useFormContext(); return ( ( field.onChange(fieldType === "string" ? "" + value : value) } isDisabled={isReadOnly} aria-label={label} /> )} /> ); };