﻿import 'babel-polyfill';
import React, { Component, PropTypes } from 'react';
import Switch from "react-switch";

class Checkbox extends Component {
constructor(){
  super();
  this.state = {
    isChecked: false
  }
}

  componentDidMount() {
    this.setState({ isChecked: this.props.checked });
  }


  toggleCheckboxChange = (e) => {
    const { IdPadre,tipo } = this.props;

    this.setState({isChecked:e});
    
    this.props.onChangeCheckBox(IdPadre,e,tipo);

  }


  render() {
    const { isChecked } = this.state;
 
    return (
      <td  className="switchSmS1 BSswitch switch-small">
         <Switch
          onChange={this.toggleCheckboxChange}
          checked={this.state.isChecked}
          onColor={'#37c480'}
        />
        {/* <div className="checkbox">
          <label>
            <input
              type="checkbox"
              checked={isChecked}
              onChange={this.toggleCheckboxChange}
            />
          </label>
        </div> */}
      </td>
    );
  }
}



export default Checkbox;