import { Controller, type Control, type FieldPath, type FieldValues } from "react-hook-form" import { FormFieldShell, type FormFieldShellProps } from "@/components/form/form-field-shell" import { DateRangeInput, type DateRangeInputProps, type DateRangeValue, } from "@/components/ui/input/date-range" export type FormDateRangeInputProps< TFieldValues extends FieldValues = FieldValues, TFromName extends FieldPath = FieldPath, TToName extends FieldPath = FieldPath, > = Omit & Pick & { control: Control fromName: TFromName toName: TToName emptyValue?: unknown onValueChange?: (value: DateRangeValue) => void } function FormDateRangeInput< TFieldValues extends FieldValues = FieldValues, TFromName extends FieldPath = FieldPath, TToName extends FieldPath = FieldPath, >({ control, fromName, toName, label, description, required, className, emptyValue = "", onValueChange, ...props }: FormDateRangeInputProps) { return ( ( { const error = fromState.error?.message ?? toState.error?.message return ( { fromField.onChange(value.from || emptyValue) toField.onChange(value.to || emptyValue) onValueChange?.(value) }} {...props} /> ) }} /> )} /> ) } export { FormDateRangeInput }