2016-09-11 23:07:48 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
import DateTime from 'react-datetime';
|
|
|
|
|
|
|
|
export default class DateTimeControl extends React.Component {
|
2016-12-01 16:28:33 -02:00
|
|
|
componentDidMount() {
|
|
|
|
if (!this.props.value) {
|
|
|
|
this.props.onChange(new Date());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleChange = (datetime) => {
|
2016-09-11 23:07:48 +02:00
|
|
|
this.props.onChange(datetime);
|
2016-10-03 14:25:27 +02:00
|
|
|
};
|
2016-09-11 23:07:48 +02:00
|
|
|
|
|
|
|
render() {
|
2016-12-01 16:28:33 -02:00
|
|
|
return <DateTime value={this.props.value} onChange={this.handleChange} />;
|
2016-09-11 23:07:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DateTimeControl.propTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
2016-12-01 16:28:33 -02:00
|
|
|
value: PropTypes.object, // eslint-disable-line
|
2016-09-11 23:07:48 +02:00
|
|
|
};
|