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

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

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

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

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