import ReactSelect from 'react-select'

const HookFormSelect = ({ field, ...props }) => (
  <ReactSelect
    classNamePrefix='form-select'
    ref={field.ref}
    onChange={(option) => field.onChange(option.value)}
    value={field.value ? props.options.find((option) => option.value === field.value) : ''}
    isDisabled={props.disabled}
    {...props}
  />
)

export default HookFormSelect
