import React from 'react';
import { ICheckboxPureProps } from './CheckboxPure.interface';

export const CheckboxPure = function Checkbox(props: ICheckboxPureProps): any {
   const { dataCy, error, title, ...rest } = props;

   return (
      <label className="checkbox-container clean" data-cy={dataCy}>
         <input type="checkbox" {...rest} />
         <span
            className={`checkbox ${error && 'has-error'} ${rest.disabled && 'disabled'}`}
            data-testid="input-checkbox-error"
         >
            <i className="fas fa-check" />
         </span>
         <span className={`title ${rest.disabled && 'disabled'}`}>{title}</span>
      </label>
   );
};
