Skip to content

Scheduling infrastructure for absolutely everyone.

fix: delete reserved slot on booker unmount (#15700)

Morgan86676eb8af18
diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx
index 25cf35aa382..4f4bc7813de 100644
--- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx
+++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx
@@ -91,28 +91,6 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
return formatUsername(props.username);
}, [props.username]);
- useEffect(() => {
- // reset booker whenever it's unmounted
- return () => {
- setBookerState("loading");
- setSelectedDate(null);
- setSelectedTimeslot(null);
- setSelectedDuration(null);
- setOrg(null);
- setSelectedMonth(null);
- setSelectedDuration(null);
- if (props.rescheduleUid) {
- // clean booking data from cache
- queryClient.removeQueries({
- queryKey: [BOOKING_RESCHEDULE_KEY, props.rescheduleUid],
- exact: true,
- });
- setBookingData(null);
- }
- };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
setSelectedDuration(props.duration ?? null);
setOrg(props.entity?.orgSlug ?? null);
@@ -304,6 +282,29 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
locationUrl: props.locationUrl,
});
+ useEffect(() => {
+ // reset booker whenever it's unmounted
+ return () => {
+ slots.handleRemoveSlot();
+ setBookerState("loading");
+ setSelectedDate(null);
+ setSelectedTimeslot(null);
+ setSelectedDuration(null);
+ setOrg(null);
+ setSelectedMonth(null);
+ setSelectedDuration(null);
+ if (props.rescheduleUid) {
+ // clean booking data from cache
+ queryClient.removeQueries({
+ queryKey: [BOOKING_RESCHEDULE_KEY, props.rescheduleUid],
+ exact: true,
+ });
+ setBookingData(null);
+ }
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
return (
<AtomsWrapper>
<BookerComponent