From 071c899ea6bd3c29ce6648c1c5525982ec249ad7 Mon Sep 17 00:00:00 2001 From: Rajiv Sahal Date: Mon, 16 Sep 2024 20:09:18 +0530 Subject: [PATCH] fix: overlay calendar view for `Booker` atom (#16642) * overlay calendar needs to be false when in month_view * fixup --- .../platform/atoms/booker/BookerPlatformWrapper.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx index 6b543b208a7848..9c079b85722c1c 100644 --- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx +++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx @@ -381,15 +381,17 @@ export const BookerPlatformWrapper = ( }); setBookingData(null); } - if (isOverlayCalendarEnabled) { - localStorage.setItem("overlayCalendarSwitchDefault", "true"); - } else { - localStorage.removeItem("overlayCalendarSwitchDefault"); - } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + useEffect(() => { + if (isOverlayCalendarEnabled && view === "MONTH_VIEW") { + localStorage.removeItem("overlayCalendarSwitchDefault"); + } + setIsOverlayCalendarEnabled(Boolean(localStorage?.getItem?.("overlayCalendarSwitchDefault"))); + }, [view, isOverlayCalendarEnabled]); + return (