|
3 | 3 | import { useMutation } from "@tanstack/react-query"; |
4 | 4 | import { useRouter } from "next/navigation"; |
5 | 5 | import { useRef, useState, useEffect } from "react"; |
| 6 | +import { shallow } from "zustand/shallow"; |
6 | 7 |
|
7 | 8 | import { createPaymentLink } from "@calcom/app-store/stripepayment/lib/client"; |
8 | 9 | import { useHandleBookEvent } from "@calcom/atoms/hooks/bookings/useHandleBookEvent"; |
9 | 10 | import dayjs from "@calcom/dayjs"; |
10 | 11 | import { sdkActionManager } from "@calcom/embed-core/embed-iframe"; |
11 | 12 | import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider"; |
12 | | -import { useBookerStore } from "@calcom/features/bookings/Booker/store"; |
13 | 13 | import { updateQueryParam, getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param"; |
14 | 14 | import { createBooking, createRecurringBooking, createInstantBooking } from "@calcom/features/bookings/lib"; |
15 | 15 | import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking"; |
@@ -177,9 +177,15 @@ export const useBookings = ({ |
177 | 177 | const eventTypeId = useBookerStoreContext((state) => state.eventId); |
178 | 178 | const isInstantMeeting = useBookerStoreContext((state) => state.isInstantMeeting); |
179 | 179 |
|
180 | | - const rescheduleUid = useBookerStoreContext((state) => state.rescheduleUid); |
| 180 | + const [rescheduleUid, setRescheduleUid] = useBookerStoreContext( |
| 181 | + (state) => [state.rescheduleUid, state.setRescheduleUid], |
| 182 | + shallow |
| 183 | + ); |
181 | 184 | const rescheduledBy = useBookerStoreContext((state) => state.rescheduledBy); |
182 | | - const bookingData = useBookerStoreContext((state) => state.bookingData); |
| 185 | + const [bookingData, setBookingData] = useBookerStoreContext( |
| 186 | + (state) => [state.bookingData, state.setBookingData], |
| 187 | + shallow |
| 188 | + ); |
183 | 189 | const timeslot = useBookerStoreContext((state) => state.selectedTimeslot); |
184 | 190 | const { t } = useLocale(); |
185 | 191 | const bookingSuccessRedirect = useBookingSuccessRedirect(); |
@@ -383,16 +389,12 @@ export const useBookings = ({ |
383 | 389 | }; |
384 | 390 |
|
385 | 391 | if (error.message === ErrorCode.BookerLimitExceededReschedule && error.data?.rescheduleUid) { |
386 | | - useBookerStore.setState({ |
387 | | - rescheduleUid: error.data?.rescheduleUid, |
388 | | - }); |
389 | | - useBookerStore.setState({ |
390 | | - bookingData: { |
391 | | - uid: error.data?.rescheduleUid, |
392 | | - startTime: error.data?.startTime, |
393 | | - attendees: error.data?.attendees, |
394 | | - } as unknown as GetBookingType, |
395 | | - }); |
| 392 | + setRescheduleUid(error.data?.rescheduleUid); |
| 393 | + setBookingData({ |
| 394 | + uid: error.data?.rescheduleUid, |
| 395 | + startTime: error.data?.startTime, |
| 396 | + attendees: error.data?.attendees, |
| 397 | + } as unknown as GetBookingType); |
396 | 398 | } |
397 | 399 | }, |
398 | 400 | }); |
|
0 commit comments