{"size": 1248, "ext": "js", "max_stars_repo_path": "src2/components/checkbox/index.js", "max_stars_repo_name": "CUNOVS/BJ-Open-University", "max_stars_repo_stars_event_min_datetime": "2020-08-07T13:51:52.000Z", "max_stars_repo_stars_event_max_datetime": "2020-08-07T13:51:52.000Z", "max_issues_repo_path": "src2/components/checkbox/index.js", "max_issues_repo_name": "CUNOVS/BJ-Open-University", "max_issues_repo_issues_event_min_datetime": "2021-01-05T03:15:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-05T03:15:45.000Z", "max_forks_repo_path": "src2/components/checkbox/index.js", "max_forks_repo_name": "CUNOVS/BJ-Open-University", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 26.5531914894, "max_line_length": 78, "alphanum_fraction": 0.6177884615}
/**
 * @author Lowkey
 * @date 2019/03/12 15:46:01
 * @Description:
 */

import React from 'react';
import { Icon } from 'antd-mobile';
import { getLocalIcon } from 'utils';
import PropTypes from 'prop-types';
import styles from './index.less';

const getIcon = (state) => {
  const newState = parseInt(state, 10);
  if (newState === 1) {
    return <Icon type={getLocalIcon('/checkbox/completion-auto-pass.svg')} />;
  } else if (newState === 2) {
    return <Icon type={getLocalIcon('/checkbox/completion-auto-pass.svg')} />;
  } else if (newState === 3) {
    return <Icon type={getLocalIcon('/checkbox/completion-auto-fail.svg')} />;
  } else {
    return <Icon type={getLocalIcon('/checkbox/completion-manual-n.svg')} />;
  }
};

const Checkbox = (props) => {
  const { state, tracking = '1' } = props;
  if (tracking === '2') {
    return (
      <div className={styles.outer} onClick={props.handlerClick} >
        {getIcon(state)}
      </div >
    );
  } else if (tracking === '1') {
    return (
      <div className={styles.outer} onClick={props.handlerClick} >
        {getIcon(state)}
      </div >
    );
  }
};
Checkbox.defaultProps = {};
Checkbox.propTypes = {
  handlerClick: PropTypes.func.isRequired,
};
export default Checkbox;
