@@ -139,21 +139,33 @@ const BookerPlatformWrapperComponent = (props: BookerWebWrapperAtomProps) => {
139139
140140 const isEmbed = useIsEmbed ( ) ;
141141
142+ const _month = dayjs ( date ) . month ( ) ;
143+ const _monthAfterAdding1Month = dayjs ( date ) . add ( 1 , "month" ) . month ( ) ;
144+ const _monthAfterAddingExtraDays = dayjs ( date ) . add ( bookerLayout . extraDays , "day" ) . month ( ) ;
145+ const _monthAfterAddingExtraDaysColumnView = dayjs ( date )
146+ . add ( bookerLayout . columnViewExtraDays . current , "day" )
147+ . month ( ) ;
148+
149+ const _isValidDate = dayjs ( date ) . isValid ( ) ;
150+ const _2WeeksAfter = dayjs ( month ) . startOf ( "month" ) . add ( 2 , "week" ) ;
151+ const _isSameMonth = dayjs ( ) . isSame ( dayjs ( month ) , "month" ) ;
152+ const _isAfter2Weeks = dayjs ( ) . isAfter ( _2WeeksAfter ) ;
153+
142154 const prefetchNextMonth =
143155 ( bookerLayout . layout === BookerLayouts . WEEK_VIEW &&
144156 ! ! bookerLayout . extraDays &&
145- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . extraDays , "day" ) . month ( ) ) ||
146- ( bookerLayout . layout === BookerLayouts . COLUMN_VIEW &&
147- dayjs ( date ) . month ( ) !== dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( ) ) ||
157+ _month !== _monthAfterAddingExtraDays ) ||
158+ ( bookerLayout . layout === BookerLayouts . COLUMN_VIEW && _month !== _monthAfterAddingExtraDaysColumnView ) ||
148159 ( ( bookerLayout . layout === BookerLayouts . MONTH_VIEW || bookerLayout . layout === "mobile" ) &&
149- ( ! dayjs ( date ) . isValid ( ) || dayjs ( ) . isSame ( dayjs ( month ) , "month" ) ) &&
150- dayjs ( ) . isAfter ( dayjs ( month ) . startOf ( "month" ) . add ( 2 , "week" ) ) ) ;
160+ ( ! _isValidDate || _isSameMonth ) &&
161+ _isAfter2Weeks ) ;
151162
152163 const monthCount =
153164 ( ( bookerLayout . layout !== BookerLayouts . WEEK_VIEW && bookerState === "selecting_time" ) ||
154165 bookerLayout . layout === BookerLayouts . COLUMN_VIEW ) &&
155- dayjs ( date ) . add ( 1 , "month" ) . month ( ) !==
156- dayjs ( date ) . add ( bookerLayout . columnViewExtraDays . current , "day" ) . month ( )
166+ ! isNaN ( _monthAfterAdding1Month ) &&
167+ ! isNaN ( _monthAfterAddingExtraDaysColumnView ) &&
168+ _monthAfterAdding1Month !== _monthAfterAddingExtraDaysColumnView
157169 ? 2
158170 : undefined ;
159171 /**
0 commit comments