/* eslint-disable */ // @ts-nocheck import { Controller, FieldValues, FieldPath, UseControllerProps, PathValue, useFormContext, } from "react-hook-form"; import { SwitchProps, Switch } from "../../@patternfly/react-core"; import { ReactNode } from "react"; import { FormLabel } from "./FormLabel"; import { debeerify } from "../user-profile/utils"; export type SwitchControlProps< T extends FieldValues, P extends FieldPath = FieldPath, > = Omit & UseControllerProps & { name: string; label?: string; labelIcon?: string | ReactNode; labelOn: string; labelOff: string; stringify?: boolean; }; export const SwitchControl = < T extends FieldValues, P extends FieldPath = FieldPath, >({ labelOn, stringify, defaultValue, labelIcon, ...props }: SwitchControlProps) => { const fallbackValue = stringify ? "false" : false; const defValue = defaultValue ?? (fallbackValue as PathValue); const { control } = useFormContext(); return ( ( { const value = stringify ? checked.toString() : checked; props.onChange?.(e, checked); onChange(value); }} /> )} /> ); };