Skip to content

Commit

Permalink
fix: delete reserved slot on booker unmount (calcom#15700)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThyMinimalDev authored and p6l-richard committed Jul 22, 2024
1 parent d7bf0d0 commit ebf2622
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions packages/platform/atoms/booker/BookerPlatformWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ebf2622

Please sign in to comment.