Skip to content

Commit

Permalink
Fix bug for date fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gocreating committed Nov 29, 2016
1 parent 40f93de commit b4dd883
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/common/components/fields/bases/AirDateRange.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react';
import { DateRangePicker } from 'react-dates';
import moment from 'moment';

let defaultValue = {
startDate: null,
Expand Down Expand Up @@ -37,8 +38,16 @@ class AirDateRange extends Component {
onDatesChange={this.onDatesChange}
onFocusChange={this.onFocusChange}
focusedInput={focusedInput}
startDate={input.value.startDate || defaultValue.startDate}
endDate={input.value.endDate || defaultValue.endDate}
startDate={
input.value.startDate ?
moment(input.value.startDate) :
defaultValue.startDate
}
endDate={
input.value.endDate ?
moment(input.value.endDate) :
defaultValue.endDate
}
/>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/components/fields/bases/AirSingleDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component, PropTypes } from 'react';
import { SingleDatePicker } from 'react-dates';
import moment from 'moment';

let defaultValue = null;

Expand Down Expand Up @@ -33,7 +34,7 @@ class AirSingleDate extends Component {
{...rest}
id="date_input"
focused={focused}
date={input.value || defaultValue}
date={input.value ? moment(input.value) : defaultValue}
onDateChange={this.onDateChange}
onFocusChange={this.onFocusChange}
/>
Expand Down

0 comments on commit b4dd883

Please sign in to comment.