2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-01 13:02:53 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
import DatePicker from 'react-datepicker/dist/react-datepicker';
|
2015-06-01 13:02:53 +02:00
|
|
|
|
|
|
|
let InputDate = React.createClass({
|
2015-06-09 16:10:38 +02:00
|
|
|
propTypes: {
|
|
|
|
submitted: React.PropTypes.bool,
|
2015-08-06 10:58:09 +02:00
|
|
|
placeholderText: React.PropTypes.string,
|
|
|
|
onChange: React.PropTypes.func
|
2015-06-09 16:10:38 +02:00
|
|
|
},
|
2015-06-01 13:02:53 +02:00
|
|
|
|
|
|
|
getInitialState() {
|
2015-06-05 11:06:36 +02:00
|
|
|
return {
|
2015-07-15 14:48:51 +02:00
|
|
|
value: null
|
2015-06-01 13:02:53 +02:00
|
|
|
};
|
|
|
|
},
|
2015-06-01 14:49:13 +02:00
|
|
|
|
|
|
|
handleChange(date) {
|
2015-07-15 14:48:51 +02:00
|
|
|
let formattedDate = date.format('YYYY-MM-DD');
|
2015-06-02 18:43:37 +02:00
|
|
|
this.setState({
|
2015-07-15 14:48:51 +02:00
|
|
|
value: formattedDate,
|
|
|
|
value_moment: date
|
|
|
|
});
|
|
|
|
|
|
|
|
this.props.onChange({
|
|
|
|
target: {
|
|
|
|
value: formattedDate
|
|
|
|
}
|
|
|
|
});
|
2015-06-01 13:02:53 +02:00
|
|
|
},
|
2015-06-01 14:49:13 +02:00
|
|
|
|
2015-06-01 13:02:53 +02:00
|
|
|
render: function () {
|
|
|
|
return (
|
2015-07-29 14:49:36 +02:00
|
|
|
<div>
|
2015-06-02 18:43:37 +02:00
|
|
|
<DatePicker
|
|
|
|
dateFormat="YYYY-MM-DD"
|
2015-07-15 14:48:51 +02:00
|
|
|
selected={this.state.value_moment}
|
2015-06-02 18:43:37 +02:00
|
|
|
onChange={this.handleChange}
|
|
|
|
placeholderText={this.props.placeholderText}/>
|
|
|
|
</div>
|
2015-06-01 13:02:53 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-06-01 14:49:13 +02:00
|
|
|
export default InputDate;
|