From 7fea0b55f7e90fc64b6f3e522e67a24c2f04e109 Mon Sep 17 00:00:00 2001 From: Bastieno Date: Wed, 11 Dec 2024 10:37:14 +0100 Subject: [PATCH] fix: mountCount issues --- .../booker/wrappers/BookerWebWrapper.tsx | 19 +++++++++++-------- packages/features/calendars/DatePicker.tsx | 3 +-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/atoms/booker/wrappers/BookerWebWrapper.tsx b/packages/atoms/booker/wrappers/BookerWebWrapper.tsx index f9be6f4be75ea3..ff5f0064098ca4 100644 --- a/packages/atoms/booker/wrappers/BookerWebWrapper.tsx +++ b/packages/atoms/booker/wrappers/BookerWebWrapper.tsx @@ -51,7 +51,6 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => { org: props.entity.orgSlug, }); - const [bookerState, _] = useBookerStore((state) => [state.state, state.setState], shallow); const [dayCount] = useBookerStore((state) => [state.dayCount, state.setDayCount], shallow); const { data: session } = useSession(); const routerQuery = useRouterQuery(); @@ -100,13 +99,17 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => { }); const slots = useSlots(event); - const monthCount = - ((bookerLayout.layout !== BookerLayouts.WEEK_VIEW && bookerState === "selecting_time") || - bookerLayout.layout === BookerLayouts.COLUMN_VIEW) && - dayjs(date).add(1, "month").month() !== - dayjs(date).add(bookerLayout.columnViewExtraDays.current, "day").month() - ? 2 - : undefined; + const monthCount = useMemo(() => { + if ( + bookerLayout.layout === BookerLayouts.COLUMN_VIEW && + dayjs(date).add(1, "month").month() !== + dayjs(date).add(bookerLayout.columnViewExtraDays.current, "day").month() + ) { + return 2; + } + + return undefined; + }, [bookerLayout.columnViewExtraDays, bookerLayout.layout, date]); /** * Prioritize dateSchedule load * Component will render but use data already fetched from here, and no duplicate requests will be made diff --git a/packages/features/calendars/DatePicker.tsx b/packages/features/calendars/DatePicker.tsx index 08bf28cc552ed8..82a31cf3ade4c7 100644 --- a/packages/features/calendars/DatePicker.tsx +++ b/packages/features/calendars/DatePicker.tsx @@ -422,8 +422,7 @@ const Days = ({ { - const dayIsInNextMonth = day?.month() === browsingDate.add(1, "month").month(); - props.onChange(day, dayIsInNextMonth); + props.onChange(day); }} disabled={disabled} active={isActive(day)}