@@ -11,12 +11,12 @@ import {
1111import { Header } from "@calcom/features/bookings/Booker/components/Header" ;
1212import { BookerSection } from "@calcom/features/bookings/Booker/components/Section" ;
1313import { useBookerLayout } from "@calcom/features/bookings/Booker/components/hooks/useBookerLayout" ;
14+ import { usePrefetch } from "@calcom/features/bookings/Booker/components/hooks/usePrefetch" ;
1415import { useTimePreferences } from "@calcom/features/bookings/lib" ;
1516import { LargeCalendar } from "@calcom/features/calendar-view/LargeCalendar" ;
1617import { getUsernameList } from "@calcom/features/eventtypes/lib/defaultEvents" ;
1718import { useTimesForSchedule } from "@calcom/features/schedules/lib/use-schedule/useTimesForSchedule" ;
1819import { getRoutedTeamMemberIdsFromSearchParams } from "@calcom/lib/bookings/getRoutedTeamMemberIdsFromSearchParams" ;
19- import { BookerLayouts } from "@calcom/prisma/zod-utils" ;
2020
2121import { formatUsername } from "../../booker/BookerPlatformWrapper" ;
2222import type {
@@ -40,7 +40,6 @@ const CalendarViewPlatformWrapperComponent = (
4040 teamMemberEmail,
4141 crmAppSlug,
4242 crmOwnerRecordType,
43- view = "MONTH_VIEW" ,
4443 } = props ;
4544
4645 const teamId : number | undefined = props . isTeamEvent ? props . teamId : undefined ;
@@ -73,22 +72,15 @@ const CalendarViewPlatformWrapperComponent = (
7372 ) ;
7473 const selectedDate = useBookerStoreContext ( ( state ) => state . selectedDate ) ;
7574 const date = dayjs ( selectedDate ) . format ( "YYYY-MM-DD" ) ;
76- const monthCount =
77- ( ( bookerLayout . layout !== BookerLayouts . WEEK_VIEW && bookerState === "selecting_time" ) ||
78- bookerLayout . layout === BookerLayouts . COLUMN_VIEW ) &&
79- dayjs ( date ) . add ( 1 , "month" ) . month ( ) !==
80- dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( )
81- ? 2
82- : undefined ;
8375 const month = useBookerStoreContext ( ( state ) => state . month ) ;
8476 const [ dayCount ] = useBookerStoreContext ( ( state ) => [ state . dayCount , state . setDayCount ] , shallow ) ;
8577
86- const prefetchNextMonth =
87- ( bookerLayout . layout === BookerLayouts . WEEK_VIEW &&
88- ! ! bookerLayout . extraDays &&
89- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . extraDays , "day" ) . month ( ) ) ||
90- ( bookerLayout . layout === BookerLayouts . COLUMN_VIEW &&
91- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( ) ) ;
78+ const { prefetchNextMonth, monthCount } = usePrefetch ( {
79+ date ,
80+ month ,
81+ bookerLayout,
82+ bookerState ,
83+ } ) ;
9284
9385 const [ startTime , endTime ] = useTimesForSchedule ( {
9486 month,
@@ -136,7 +128,6 @@ const CalendarViewPlatformWrapperComponent = (
136128 } , [ props . routingFormSearchParams ] ) ;
137129 const bookingData = useBookerStoreContext ( ( state ) => state . bookingData ) ;
138130 const setBookingData = useBookerStoreContext ( ( state ) => state . setBookingData ) ;
139- const layout = BookerLayouts [ view ] ;
140131
141132 useGetBookingForReschedule ( {
142133 uid : props . rescheduleUid ?? props . bookingUid ?? "" ,
@@ -154,7 +145,7 @@ const CalendarViewPlatformWrapperComponent = (
154145 eventId : event ?. data ?. id ,
155146 rescheduleUid : props . rescheduleUid ?? null ,
156147 bookingUid : props . bookingUid ?? null ,
157- layout : layout ,
148+ layout : "week_view" ,
158149 org : props . entity ?. orgSlug ,
159150 username,
160151 bookingData,
0 commit comments