From 68d0090f50e5b2ed8eaea63b1c068dd2f84dc226 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Tue, 27 Feb 2024 16:21:11 +0530 Subject: [PATCH] Make sure that state doesnt reset (#13880) --- .../bookings/Booker/components/Header.tsx | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/features/bookings/Booker/components/Header.tsx b/packages/features/bookings/Booker/components/Header.tsx index eb7dc45f02..7f92d8a8a5 100644 --- a/packages/features/bookings/Booker/components/Header.tsx +++ b/packages/features/bookings/Booker/components/Header.tsx @@ -55,13 +55,6 @@ export function Header({ if (isMobile || !enabledLayouts) return null; - // Only reason we create this component, is because it is used 3 times in this component, - // and this way we can't forget to update one of the props in all places :) - const LayoutToggleWithData = () => { - return enabledLayouts.length <= 1 ? null : ( - - ); - }; // In month view we only show the layout toggle. if (isMonthView) { return ( @@ -78,7 +71,11 @@ export function Header({ ) : ( renderOverlay?.() )} - + ); } @@ -140,7 +137,11 @@ export function Header({ {renderOverlay?.()}
- +
{/* This second layout toggle is hidden, but needed to reserve the correct spot in the DIV @@ -150,7 +151,11 @@ export function Header({ while it actually already was on place. That's why we have this element twice. */}
- +
@@ -198,3 +203,17 @@ const LayoutToggle = ({ return ; }; + +const LayoutToggleWithData = ({ + enabledLayouts, + onLayoutToggle, + layout, +}: { + enabledLayouts: BookerLayouts[]; + onLayoutToggle: (layout: string) => void; + layout: string; +}) => { + return enabledLayouts.length <= 1 ? null : ( + + ); +};