From 4258da1df5a7f48d6a05381d6316a52234ab1b09 Mon Sep 17 00:00:00 2001 From: alannnc Date: Mon, 4 Sep 2023 16:10:19 -0700 Subject: [PATCH] remove double call on useSchedule() (#11141) --- packages/features/bookings/Booker/Booker.tsx | 6 +++--- packages/features/schedules/lib/use-schedule/useSchedule.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/features/bookings/Booker/Booker.tsx b/packages/features/bookings/Booker/Booker.tsx index d273d11fdf..7459b4d599 100644 --- a/packages/features/bookings/Booker/Booker.tsx +++ b/packages/features/bookings/Booker/Booker.tsx @@ -49,7 +49,7 @@ const BookerComponent = ({ * Prioritize dateSchedule load * Component will render but use data already fetched from here, and no duplicate requests will be made * */ - useScheduleForEvent({ + const schedule = useScheduleForEvent({ prefetchNextMonth: false, username, eventSlug, @@ -93,7 +93,7 @@ const BookerComponent = ({ ); const date = dayjs(selectedDate).format("YYYY-MM-DD"); - const schedule = useScheduleForEvent({ prefetchNextMonth: true }); + const nonEmptyScheduleDays = useNonEmptyScheduleDays(schedule?.data?.slots).filter( (slot) => dayjs(selectedDate).diff(slot, "day") <= 0 ); @@ -109,7 +109,7 @@ const BookerComponent = ({ ? totalWeekDays : 0; - //Taking one more avaliable slot(extraDays + 1) to claculate the no of days in between, that next and prev button need to shift. + // Taking one more available slot(extraDays + 1) to calculate the no of days in between, that next and prev button need to shift. const availableSlots = nonEmptyScheduleDays.slice(0, extraDays + 1); if (nonEmptyScheduleDays.length !== 0) columnViewExtraDays.current = diff --git a/packages/features/schedules/lib/use-schedule/useSchedule.ts b/packages/features/schedules/lib/use-schedule/useSchedule.ts index 4e8aeac4a6..8d6d28327c 100644 --- a/packages/features/schedules/lib/use-schedule/useSchedule.ts +++ b/packages/features/schedules/lib/use-schedule/useSchedule.ts @@ -31,7 +31,7 @@ export const useSchedule = ({ const nextMonthDayjs = monthDayjs.add(monthCount ? monthCount : 1, "month"); // Why the non-null assertions? All of these arguments are checked in the enabled condition, // and the query will not run if they are null. However, the check in `enabled` does - // no satisfy typscript. + // no satisfy typescript. return trpc.viewer.public.slots.getSchedule.useQuery( { isTeamEvent,