@@ -15,6 +15,7 @@ import {
1515import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout" ;
1616import { useBookingForm } from "@calcom/features/bookings/Booker/components/hooks/useBookingForm" ;
1717import { useLocalSet } from "@calcom/features/bookings/Booker/components/hooks/useLocalSet" ;
18+ import { usePrefetch } from "@calcom/features/bookings/Booker/components/hooks/usePrefetch" ;
1819import { useInitializeBookerStore } from "@calcom/features/bookings/Booker/store" ;
1920import { useTimePreferences } from "@calcom/features/bookings/lib" ;
2021import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule" ;
@@ -92,6 +93,7 @@ const BookerPlatformWrapperComponent = (
9293 ) ;
9394 const prevStateRef = useRef < BookerStoreValues | null > ( null ) ;
9495 const bookerStoreContext = useContext ( BookerStoreContext ) ;
96+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9597 const getStateValues = useCallback ( ( state : any ) : BookerStoreValues => {
9698 return Object . fromEntries (
9799 Object . entries ( state ) . filter ( ( [ _ , value ] ) => typeof value !== "function" )
@@ -147,10 +149,12 @@ const BookerPlatformWrapperComponent = (
147149
148150 useEffect ( ( ) => {
149151 setSelectedDuration ( props . duration ?? null ) ;
152+ // eslint-disable-next-line react-hooks/exhaustive-deps
150153 } , [ props . duration ] ) ;
151154
152155 useEffect ( ( ) => {
153156 setOrg ( props . entity ?. orgSlug ?? null ) ;
157+ // eslint-disable-next-line react-hooks/exhaustive-deps
154158 } , [ props . entity ?. orgSlug ] ) ;
155159
156160 const isDynamic = useMemo ( ( ) => {
@@ -223,30 +227,20 @@ const BookerPlatformWrapperComponent = (
223227 name : prefillFormParamName ,
224228 guests : defaultGuests ?? [ ] ,
225229 } ;
230+ // eslint-disable-next-line react-hooks/exhaustive-deps
226231 } , [ defaultName , defaultGuests ] ) ;
227232
228233 const extraOptions = useMemo ( ( ) => {
229234 return restFormValues ;
230235 } , [ restFormValues ] ) ;
231236 const date = dayjs ( selectedDate ) . format ( "YYYY-MM-DD" ) ;
232237
233- const prefetchNextMonth =
234- ( bookerLayout . layout === BookerLayouts . WEEK_VIEW &&
235- ! ! bookerLayout . extraDays &&
236- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . extraDays , "day" ) . month ( ) ) ||
237- ( bookerLayout . layout === BookerLayouts . COLUMN_VIEW &&
238- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( ) ) ||
239- ( ( bookerLayout . layout === BookerLayouts . MONTH_VIEW || bookerLayout . layout === "mobile" ) &&
240- ( ! dayjs ( date ) . isValid ( ) || dayjs ( ) . isSame ( dayjs ( month ) , "month" ) ) &&
241- dayjs ( ) . isAfter ( dayjs ( month ) . startOf ( "month" ) . add ( 2 , "week" ) ) ) ;
242-
243- const monthCount =
244- ( ( bookerLayout . layout !== BookerLayouts . WEEK_VIEW && bookerState === "selecting_time" ) ||
245- bookerLayout . layout === BookerLayouts . COLUMN_VIEW ) &&
246- dayjs ( date ) . add ( 1 , "month" ) . month ( ) !==
247- dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( )
248- ? 2
249- : undefined ;
238+ const { prefetchNextMonth, monthCount } = usePrefetch ( {
239+ date,
240+ month,
241+ bookerLayout,
242+ bookerState,
243+ } ) ;
250244 const { timezone } = useTimePreferences ( ) ;
251245
252246 const [ calculatedStartTime , calculatedEndTime ] = useTimesForSchedule ( {
@@ -470,6 +464,7 @@ const BookerPlatformWrapperComponent = (
470464 ) ;
471465 useEffect ( ( ) => {
472466 setSelectedDate ( { date : selectedDateProp , omitUpdatingParams : true } ) ;
467+ // eslint-disable-next-line react-hooks/exhaustive-deps
473468 } , [ selectedDateProp ] ) ;
474469
475470 useEffect ( ( ) => {
0 commit comments