import { Controller } from 'react-hook-form';

import { type FormLikertSliderProps } from './types';
import LikertSlider from './index';

const FormLikertSlider = ({
  name,
  rules,
  inputProps,
}: FormLikertSliderProps) => {
  return (
    <Controller
      name={name}
      rules={rules}
      render={({ field: { onChange, value, ...fieldRest } }) => (
        <LikertSlider
          {...inputProps}
          {...fieldRest}
          value={value}
          onChange={(_event, nextValue) => onChange(nextValue)}
        />
      )}
    />
  );
};

export default FormLikertSlider;
