Skip to content

Commit

Permalink
Merge pull request #129 from sharetribe/align-max-timeslots-range
Browse files Browse the repository at this point in the history
Use dayCountAvailableForBooking config in FieldDateAndTimeInput
  • Loading branch information
OtterleyW authored Jan 5, 2021
2 parents d7491b8 + f6356e0 commit d770f91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ https://github.com/sharetribe/flex-template-web/

## Upcoming version 2020-XX-XX

- [fix] Use dayCountAvailableForBooking config instead of hard-coded value in FieldDateAndTimeInput
so that it matches the date range that is used in react-dates components.
[#129](https://github.com/sharetribe/ftw-hourly/pull/129)
- [fix] Use default timezone when fetching availability exceptions if availabilityPlan and
information about listing's timezone doesn't exist yet.
[#130](https://github.com/sharetribe/ftw-hourly/pull/130)
Expand Down
7 changes: 5 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ const enableAvailability = process.env.REACT_APP_AVAILABILITY_ENABLED === 'true'

// 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. Also note that available time slots can only
// be fetched for 180 days in the future.
// moment they are charged:
// https://stripe.com/docs/connect/account-balances#holding-funds
//
// See also the API reference for querying time slots:
// https://www.sharetribe.com/api-reference/marketplace.html#query-time-slots
const dayCountAvailableForBooking = 90;

// To pass environment variables to the client app in the build
Expand Down
12 changes: 11 additions & 1 deletion src/forms/BookingTimeForm/FieldDateAndTimeInput.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { func, object, string } from 'prop-types';
import classNames from 'classnames';
import config from '../../config';
import { intlShape } from '../../util/reactIntl';
import {
getStartHours,
Expand Down Expand Up @@ -28,7 +29,16 @@ import NextMonthIcon from './NextMonthIcon';
import PreviousMonthIcon from './PreviousMonthIcon';
import css from './FieldDateAndTimeInput.module.css';

const MAX_TIME_SLOTS_RANGE = 180;
// MAX_TIME_SLOTS_RANGE is the 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:
// https://stripe.com/docs/connect/account-balances#holding-funds
//
// See also the API reference for querying time slots:
// https://www.sharetribe.com/api-reference/marketplace.html#query-time-slots

const MAX_TIME_SLOTS_RANGE = config.dayCountAvailableForBooking;

const TODAY = new Date();

const endOfRange = (date, timeZone) => {
Expand Down

0 comments on commit d770f91

Please sign in to comment.