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 AlertMixin from '../../mixins/alert_mixin';
|
|
|
|
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,
|
|
|
|
placeholderText: React.PropTypes.string
|
|
|
|
},
|
2015-06-01 13:02:53 +02:00
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
mixins: [AlertMixin],
|
2015-06-01 13:02:53 +02:00
|
|
|
|
|
|
|
getInitialState() {
|
2015-06-05 11:06:36 +02:00
|
|
|
return {
|
|
|
|
value: null,
|
2015-06-05 11:40:49 +02:00
|
|
|
value_formatted: null,
|
2015-06-05 11:06:36 +02:00
|
|
|
alerts: null // needed in AlertMixin
|
2015-06-01 13:02:53 +02:00
|
|
|
};
|
|
|
|
},
|
2015-06-01 14:49:13 +02:00
|
|
|
|
|
|
|
handleChange(date) {
|
2015-06-02 18:43:37 +02:00
|
|
|
this.setState({
|
|
|
|
value: date,
|
2015-06-09 16:10:38 +02:00
|
|
|
value_formatted: date.format('YYYY-MM-DD')});
|
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 () {
|
|
|
|
let alerts = (this.props.submitted) ? null : this.state.alerts;
|
|
|
|
return (
|
2015-06-02 18:43:37 +02:00
|
|
|
<div className="form-group">
|
|
|
|
{alerts}
|
|
|
|
<DatePicker
|
|
|
|
key="example2"
|
|
|
|
dateFormat="YYYY-MM-DD"
|
|
|
|
selected={this.state.value}
|
|
|
|
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;
|