import { useTranslate } from '@/hooks/common-hooks'; import { cn } from '@/lib/utils'; import { useFormContext } from 'react-hook-form'; import { SingleFormSlider } from '../ui/dual-range-slider'; import { FormControl, FormField, FormItem, FormLabel, FormMessage, } from '../ui/form'; import { NumberInput } from '../ui/input'; import { Switch } from '../ui/switch'; type SliderInputSwitchFormFieldProps = { max?: number; min?: number; step?: number; name: string; label: string; defaultValue?: number; onChange?: (value: number) => void; className?: string; checkName: string; numberInputClassName?: string; }; export function SliderInputSwitchFormField({ max, min, step, label, name, defaultValue, onChange, className, checkName, numberInputClassName, }: SliderInputSwitchFormFieldProps) { const form = useFormContext(); const disabled = !form.watch(checkName); const { t } = useTranslate('chat'); return ( ( {t(label)}
( )} /> { onChange?.(value); field.onChange(value); }} max={max} min={min} step={step} disabled={disabled} > { onChange?.(value); field.onChange(value); }} >
)} /> ); }