import React from 'react';
import * as actions from './actions.js';
import { connect } from 'react-redux';
import FormField from './forms/FormField.js';

class OccurrencesInput extends React.Component {
    render() {
        return (
            <div className="OccurrencesInput">
            	<FormField value={this.props.formData.allowedOccurances} className="half_width" type='TextField' isRequired={true} onChange={(e)=>this.props.handleEndsOnOccurenceInput(e)} />
            	<span>occurrences</span>
            </div>
        );
    }
};

const mapStateToProps = (state) =>{
	console.log("****** when.js state:", state.toJS());
	return {
		formData:state.get('whenReducer').get('formData').toJS()
	}
}

export default connect(mapStateToProps,actions)(OccurrencesInput)