CheckBox.js 1.76 KB
import React, { Component } from 'react';

import * as SelectActionCreators from '../../actions/profilationSelect'
import {connect} from 'react-redux';
/*

API


<CheckBox value={} name={} onChange={}>
	Testo label
</CheckBox>

*/

class CheckBox extends Component{

	render(){
		var className=''
		if(typeof this.props.className!== 'undefined'){
			className=this.props.className
		}
		return(
			<div className={"choice-ct checkbox-component "+className}>
	                <p>
	                  <input type="checkbox" id={this.props.name} name={this.props.name} className="samefile" 
	                  onChange={this.props.onChange} 
	                  value={this.props.value} 
	                  checked={!!this.props.value} />
	                  <label className="flex" htmlFor={this.props.name}><span className="isCheckbox"></span>
						  <span className="flex-test">
						  {this.props.children}
						  </span>
				</label>
	                </p>

	             </div>
		)
	}
}

const mapStateToProps = state => {
  return {

    activationSteps: state.ProfilationSelectReducer.activationSteps,
    valuesAccepted: state.ProfilationSelectReducer.valuesAccepted,
    activationAdAccepted:state.ProfilationSelectReducer.activationAdAccepted,
  commercialAccepted:state.ProfilationSelectReducer.commercialAccepted,
  }
};

const mapDispatchToProps = dispatch => ({
	updateStoreValue: (prop,value) => 
    dispatch(SelectActionCreators.changeProp(prop,value)),

  updateActivation: (index,prop,value) => dispatch(SelectActionCreators.updateActivation(index,prop,value)),
  showModal: (modalName) => 
    dispatch(SelectActionCreators.showModal(modalName)),
});


export default connect(mapStateToProps, mapDispatchToProps)(CheckBox);