mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 20:53:24 +10:00
Add a config flag for fetching availability
This commit is contained in:
parent
58cd6211b1
commit
8c2033ccc6
2 changed files with 22 additions and 13 deletions
|
|
@ -36,6 +36,10 @@ const bookingProcessAlias = 'preauth-with-nightly-booking/release-1';
|
|||
// translations when the unit is changed.
|
||||
const bookingUnitType = 'line-item/night';
|
||||
|
||||
// Should the application fetch available time slots (currently defined as
|
||||
// start and end dates) to be shown on listing page.
|
||||
const fetchAvailableTimeSlots = false;
|
||||
|
||||
// A maximum number of days forwards during which a booking can be made.
|
||||
// This is limited due to Stripe holding funds up to 90 days from the
|
||||
// moment they are charged.
|
||||
|
|
@ -318,6 +322,7 @@ const config = {
|
|||
locale,
|
||||
bookingProcessAlias,
|
||||
bookingUnitType,
|
||||
fetchAvailableTimeSlots,
|
||||
dayCountAvailableForBooking,
|
||||
i18n,
|
||||
sdk: {
|
||||
|
|
|
|||
|
|
@ -230,18 +230,22 @@ export const loadData = (params, search) => dispatch => {
|
|||
return dispatch(showListing(listingId, true));
|
||||
}
|
||||
|
||||
// fetch time slots for 90 days starting today
|
||||
// as the booking can only be done for 90 days
|
||||
// in the future due to Stripe limitations
|
||||
const start = moment().toDate();
|
||||
const end = moment()
|
||||
.add(config.dayCountAvailableForBooking, 'days')
|
||||
.toDate();
|
||||
const timeSlotsParams = { listingId, start, end };
|
||||
if (config.fetchAvailableTimeSlots) {
|
||||
// fetch time slots for 90 days starting today
|
||||
// as the booking can only be done for 90 days
|
||||
// in the future due to Stripe limitations
|
||||
const start = moment().toDate();
|
||||
const end = moment()
|
||||
.add(config.dayCountAvailableForBooking, 'days')
|
||||
.toDate();
|
||||
const timeSlotsParams = { listingId, start, end };
|
||||
|
||||
return Promise.all([
|
||||
dispatch(showListing(listingId)),
|
||||
dispatch(fetchTimeSlots(timeSlotsParams)),
|
||||
dispatch(fetchReviews(listingId)),
|
||||
]);
|
||||
return Promise.all([
|
||||
dispatch(showListing(listingId)),
|
||||
dispatch(fetchTimeSlots(timeSlotsParams)),
|
||||
dispatch(fetchReviews(listingId)),
|
||||
]);
|
||||
} else {
|
||||
return Promise.all([dispatch(showListing(listingId)), dispatch(fetchReviews(listingId))]);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue