import React from 'react';
import cx from 'classnames';

interface types {
  checked?: boolean;
  className?: string;
  hasError?: boolean;
  onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

export function Radio({ checked, className, hasError, ...rest }: types) {
  const classes = cx(`gc-radio ${className}`, {
    'gc-radio-error': hasError,
  });

  return <input type="radio" className={classes} checked={checked} {...rest} />;
}

Radio.defaultProps = {
  checked: false,
  className: '',
  hasError: false,
  onChange() {},
};
