sharetribe / web-template

Sharetribe Web Template - starting point to create a client app to your marketplace
Other
31 stars 136 forks source link

Create custom DatePicker component and remove react-dates #453

Closed Gnito closed 2 weeks ago

Gnito commented 2 months ago

This pull requests removes React Dates library from the codebase. It's an outdated library that uses deprecated React life cycle functions: componentWillReceiveProps & componentWillUpdate. React v17 will remove those functions.

Instead of a datepicker based on React Dates, this includes a custom DatePicker component. The custom picker should look almost the same as the previous one, but there are couple of changes:

Screenshot 2024-10-28 at 18 04 34

There are 2 different input mechanisms:

This datepicker change affects several places in code:

In addition, this PR also changes the timeSlot handling a bit. Returned timeSlots are processed so that if there are 2 timeSlots back-to-back (1 timeSlot ends with the same timestamp as the next starts) and they have the same seats count, those timeSlots are joined into a single timeSlot.

Background: The booking calendar fetches timeSlots for each month. For day & night based availability this has worked fine as we only check if day has availability or not. However, there has been an issue with hour-based listings: we haven't had good setup for multi-day bookings with hour-based listings. This is because timeslots.query returns availability between given start and end times - and therefore, separate fetches for each month creates artificial borders which breaks continuous availability.

This makes it easier for customizers to add bookings that take advantage of differently priced time-units with bookings that pan over a long time window.

For example: Bicycle rental has day price of $100 & hour price $5. Customer rents it between 3:00 pm on Nov 15, 2024 and 10:00 am on Nov 18, 2024. Pricing calculation could work like this:

  • Full days: 3 * $100 per day => $300
  • Extra hours: 19 * $5 per hour => $95

Total: $395

Note: this scenario assumes that hour-based availability is used with the listing type. The 'day' and 'night' time units reserve the given day (00:00 - 24:00) on the listing's time zone. So, they operate with a bit different availability concept.

Translation changes

  "DatePicker.clearButton": "Clear value",
  "DatePicker.screenreader.blockedDate": "{date} is not available",
  "DatePicker.screenreader.chooseDate": "Choose {date}",
  "DatePicker.screenreader.chooseEndDate": "Choose {date} as the end date",
  "DatePicker.screenreader.chooseStartDate": "Choose {date} as the start date",
  "DatePicker.screenreader.nextMonthButton": "Next month",
  "DatePicker.screenreader.previousMonthButton": "Previous month",
  "DatePicker.screenreader.selectedDate": "{date} is selected",
  "DatePicker.screenreader.selectedEndDate": "{date} is selected as the end date",
  "DatePicker.screenreader.selectedStartDate": "{date} is selected as the start date",
  "DatePicker.todayButton": "Show today",

Note: