Format time display

pull/10616/head
Andrew Watkins 2017-03-29 09:58:29 -07:00
parent e3282bc505
commit adbaec0089
1 changed files with 15 additions and 10 deletions

View File

@ -16,11 +16,13 @@ class CustomTimeRange extends Component {
} }
componentDidMount() { componentDidMount() {
const lower = rome(this.timeLower, { const {timeRange} = this.props
initialValue: this._formatTimeRange(this.props.timeLower),
const lower = rome(this.lower, {
initialValue: this._formatTimeRange(timeRange.lower),
}) })
const upper = rome(this.timeUpper, { const upper = rome(this.upper, {
initialValue: this._formatTimeRange(this.props.timeUpper), initialValue: this._formatTimeRange(timeRange.upper),
}) })
this.lowerCal = lower this.lowerCal = lower
@ -40,18 +42,18 @@ class CustomTimeRange extends Component {
} }
render() { render() {
const {isVisible, onToggle} = this.props const {isVisible, onToggle, timeRange: {upper, lower}} = this.props
return ( return (
<div className={classNames("custom-time-range", {show: isVisible})} style={{display: 'flex'}}> <div className={classNames("custom-time-range", {show: isVisible})} style={{display: 'flex'}}>
<button className="btn btn-sm btn-info" onClick={onToggle}> <button className="btn btn-sm btn-info" onClick={onToggle}>
<span className="icon clock"></span> <span className="icon clock"></span>
sfsfsdfsf {`${moment(lower).format('MMM Do HH:mm')} to ${moment(upper).format('MMM Do HH:mm')}`}
<span className="caret"></span> <span className="caret"></span>
</button> </button>
<div className="custom-time-container"> <div className="custom-time-container">
<div className="time-lower" ref={(r) => this.timeLower = r} /> <div className="time-lower" ref={(r) => this.lower = r} />
<div className="time-upper" ref={(r) => this.timeUpper = r} /> <div className="time-upper" ref={(r) => this.upper = r} />
<div className="apply-time button" onClick={this.handleClick}>Apply</div> <div className="apply-time button" onClick={this.handleClick}>Apply</div>
</div> </div>
</div> </div>
@ -90,13 +92,16 @@ class CustomTimeRange extends Component {
const { const {
bool, bool,
func, func,
shape,
string, string,
} = PropTypes } = PropTypes
CustomTimeRange.propTypes = { CustomTimeRange.propTypes = {
onApplyTimeRange: func.isRequired, onApplyTimeRange: func.isRequired,
timeLower: string, timeRange: shape({
timeUpper: string, lower: string.isRequired,
upper: string.isRequired,
}).isRequired,
isVisible: bool.isRequired, isVisible: bool.isRequired,
onToggle: func.isRequired, onToggle: func.isRequired,
onClose: func.isRequired, onClose: func.isRequired,