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

class RepeatOnWeekDayTime extends React.Component {
    render() {
		console.log(this.props);
        return (
        	<div>
				<ReactDatetime
					inputProps ={{
						placeholder : 'Select Time',
						className : 'DatePickerInput'
					}}
					className = 'DatePicker'
					open = {false}
					onChange = {(val) => {this.props.setScheduleTime(val);this.props.extractCronExpression()}}
					dateFormat={false}
                    timeFormat="LT"
                    value = {this.props.ScheduleTime}
				/>
	            <div className="RepeatOnWeekDayTime">
	            	<FormField dataSource= {this.props.RepeatOnWeekDayData}
					isRequired={true} onChange={(e,event) => {this.props.HandleChangeRepeatOnWeekDays(e,event);this.props.extractCronExpression()}} className="half_width" type='RadioGroup' title='Repeat on' isRequired={true} placeholder='Repeat on' />
	            </div>
	        </div>
        );
    }
}

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

export default connect(mapStateToProps,actions)(RepeatOnWeekDayTime)