Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onStartDateChange(e) {
let startDateString = e.target.value
let { endDate } = this.state
const { disabled, minimumNights, isOutsideRange } = this.props
const startDate = toMomentObject(startDateString, this.getDisplayFormat())
console.log(startDate)
const isEndDateBeforeStartDate = startDate
&& isBeforeDay(endDate, startDate.clone().add(minimumNights, 'days'))
const isStartDateValid = startDate
&& !isOutsideRange(startDate)
&& !(disabled === END_DATE && isEndDateBeforeStartDate)
if (isStartDateValid) {
if (isEndDateBeforeStartDate) {
endDate = null
}
this.onDatesChange({ startDate, endDate })
this.onFocusChange(END_DATE)
} else {
this.onDatesChange({
startDate: null,
endDate,
onEndDateChange(e) {
const endDateString = e.target.value
const { startDate } = this.state
const { minimumNights, isOutsideRange, keepOpenOnDateSelect } = this.props
const endDate = toMomentObject(endDateString, this.getDisplayFormat())
const isEndDateValid = endDate
&& !isOutsideRange(endDate)
&& !(startDate && isBeforeDay(endDate, startDate.clone().add(minimumNights, 'days')))
if (isEndDateValid) {
this.onDatesChange({ startDate, endDate })
if (!keepOpenOnDateSelect) this.onClearFocus()
} else {
this.onDatesChange({
startDate,
endDate: null,
})
}
}
isOutsideRange={day => isBeforeDay(day, moment())}
/>
isOutsideRange={day => isBeforeDay(day, moment())}
phrases={getCopy(copyDictionary, copy)}