* feat: Don't allow unavailable slot's booking form to be visible - Send back to slots listing * Improvements * feat: Add env variables and strategies to prevent booking failures - Added new environment variables for configuring slot reservation and availability checks - Implemented strategies to handle concurrent bookings and slot availability - Updated Booker component and related files to support new reservation and slot checking mechanisms - Added README with detailed explanation of booking prevention strategies - Configured dynamic intervals for slot and reservation queries * docs: Update Booker README with detailed slot reservation and availability explanation - Clarified slot reservation behavior when multiple users access the same booking page - Added details about `getSchedule` refetching strategies and timing - Explained how slot availability is detected and communicated to users * Support for skip confirmation form flow * feat: Enhance slot availability and reservation mechanism - Refactored slot availability checking to support multiple slots - Added tentative selected timeslots to improve booking UX - Updated trpc handler to check availability for multiple slots - Introduced new store methods for managing tentative slot selections - Improved slot reservation and availability status tracking * refactor: Improve slot availability quick check mechanism - Renamed and restructured slot availability check parameters - Extracted quick availability checks into a separate hook - Updated type definitions for slot status and availability checks - Simplified slot availability logic in Booker and related components - Maintained cached state for quick availability checks * Support minimu booking check too * change data-testid * Rneame * Fix race condition with uid cookie not set * fix tests * Remove unsded variable --------- Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2.3 KiB
2.3 KiB
Strategies to prevent error during booking
- The
getSchedulecall, fetches only those slots that are bookable including not showing the slots that are reserved by someone else.- The booking call and the get scheduled call share the same availability checking logic to avoid scenario where
getScheduleconsiders a slot as available but Booking call doesn't consider it available.
- The booking call and the get scheduled call share the same availability checking logic to avoid scenario where
- Even though a slot might be available, multiple people might have opened the same booking page and might want to book the same slot.
- We have a reservation system in place that avoid showing a slot that is reserved by someone to other people.
- The
getSchedulecall itself considers the reservations and doesn't show those slots. - When two persons open the same booking page at the same time, they might will see the same slots.
- If Person1 selects slot1, it will be reserved by Person1. Person2 still sees the slot(because
getScheduleis refetched after a long time(in minutes)). But when Person2 selects the same slot1, he will go to "Slot no-longer available" state.- Also when the Person2, comes back to the slots listing page, he will see the slot as unavailable now. It works because getSchedule would have been fetched by that time which happened when he selected the slot earlier.
- If Person1 selects slot1, it will be reserved by Person1. Person2 still sees the slot(because
- We don't check for reservation during the confirm booking call, because a reservation has lower priority then the actual booking.
"Slot no-longer available" state
- When a slot is no longer available, we disable the "Confirm" button which does the booking.
- We show a message to the user that he should select a different slot.
- To ensure that we can go to this state, whenever applicable, we do the following:
getSchedulefetching. It prevents the unavailable slot to not appear in the list.- Fetched on window focus to handle the users who have the page opened for some time then come back to it
- Fetched every 5 mins(configurable by .env) as well to handle users who are just there on the page for a long time.
- Fetched on selecting a slot.
isReservationquery. It prevents the unavailable slot to be not bookable by the User- Fetched on regular quick intervals(currently every 10s(configurable by .env)). Even though it doesn't detect actual busy/booked slots, it still avoids the attempted booking of a reserved slot.