fix: sync book event form values with bookingData (#14945)

* fix: sync book event form values with bookingData

* fixup! fix: sync book event form values with bookingData
This commit is contained in:
Morgan authored and GitHub committed 2024-05-08 15:14:40 +00:00
1 parent d15b7d8168
commit 726af4970c
3 files changed
+22 -8

No files matched your search

@@ -1,3 +1,4 @@
import { useQueryClient } from "@tanstack/react-query";
import { useMemo, useEffect } from "react";
import { shallow } from "zustand/shallow";
@@ -28,7 +29,10 @@ import type { UseCreateBookingInput } from "../hooks/useCreateBooking";
import { useCreateBooking } from "../hooks/useCreateBooking";
import { useCreateInstantBooking } from "../hooks/useCreateInstantBooking";
import { useCreateRecurringBooking } from "../hooks/useCreateRecurringBooking";
import { useGetBookingForReschedule } from "../hooks/useGetBookingForReschedule";
import {
useGetBookingForReschedule,
QUERY_KEY as BOOKING_RESCHEDULE_KEY,
} from "../hooks/useGetBookingForReschedule";
import { useHandleBookEvent } from "../hooks/useHandleBookEvent";
import { useMe } from "../hooks/useMe";
import { usePublicEvent } from "../hooks/usePublicEvent";
@@ -73,7 +77,7 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
setBookingData(data);
},
});
const queryClient = useQueryClient();
const username = useMemo(() => {
return formatUsername(props.username);
}, [props.username]);
@@ -88,6 +92,14 @@ export const BookerPlatformWrapper = (props: BookerPlatformWrapperAtomProps) =>
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);
}
};
}, []);
@@ -85,10 +85,6 @@ export default function Bookings(props: { calUsername: string; calEmail: string
router.push(`/${data.data.uid}`);
}}
duration={eventTypeDuration}
entity={{
orgSlug: "ecorp",
considerUnpublished: false,
}}
/>
)}
{bookingTitle && <p>Booking created: {bookingTitle}</p>}