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)
? disableDates.split(/,\s?/).map(day => toMomentObject(day))
: disableDates
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,
})
}
}
constructor(props) {
super(props)
if (typeof window.Popper === 'undefined') {
throw new TypeError('The Calendar require Popper.js (https://popper.js.org/)')
}
this.form = props.form
const { elements } = this.form
this.state = {
focusedInput: null,
startDate: toMomentObject(elements['check_in'].get()),
endDate: toMomentObject(elements['check_out'].get()),
isDayPickerFocused: false,
}
this.onDatesChange = this.onDatesChange.bind(this)
this.onFocusChange = this.onFocusChange.bind(this)
this.onOutsideClick = this.onOutsideClick.bind(this)
this.onDayPickerBlur = this.onDayPickerBlur.bind(this)
this.isOutsideRange = this.isOutsideRange.bind(this)
}
constructor(props) {
super(props)
if (typeof window.Popper === 'undefined') {
throw new TypeError('The Calendar require Popper.js (https://popper.js.org/)')
}
this.form = props.form
const { elements } = this.form
this.state = {
focusedInput: null,
startDate: toMomentObject(elements['check_in'].get()),
endDate: toMomentObject(elements['check_out'].get()),
isDayPickerFocused: false,
}
this.onDatesChange = this.onDatesChange.bind(this)
this.onFocusChange = this.onFocusChange.bind(this)
this.onOutsideClick = this.onOutsideClick.bind(this)
this.onDayPickerBlur = this.onDayPickerBlur.bind(this)
this.isOutsideRange = this.isOutsideRange.bind(this)
}