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

import { type FormRadioInputProps } from './types';
import RadioInput from '.';

const FormRadioInput = ({ name, inputProps, rules }: FormRadioInputProps) => {
  return (
    <Controller
      name={name}
      rules={rules}
      render={({ field, fieldState: { error } }) => (
        <RadioInput
          {...field}
          {...inputProps}
          name={name}
          error={!!error}
        />
      )}
    />
  );
};

export default FormRadioInput;
