refactor: simplify arg of useBookerLayout hook (#21425)
This commit is contained in:
1 parent
25eac5d29b
commit
2ce25f54d4
3 files changed
+6
-5
No files matched your search
@@ -15,7 +15,9 @@ import { getQueryParam } from "../../utils/query-param";
|
||||
|
||||
export type UseBookerLayoutType = ReturnType<typeof useBookerLayout>;
|
||||
|
||||
export const useBookerLayout = (event: Pick<BookerEvent, "profile"> | undefined | null) => {
|
||||
export const useBookerLayout = (
|
||||
profileBookerLayouts: BookerEvent["profile"]["bookerLayouts"] | undefined | null
|
||||
) => {
|
||||
const [_layout, setLayout] = useBookerStore((state) => [state.layout, state.setLayout], shallow);
|
||||
const isEmbed = useIsEmbed();
|
||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||
@@ -31,7 +33,7 @@ export const useBookerLayout = (event: Pick<BookerEvent, "profile"> | undefined
|
||||
const columnViewExtraDays = useRef<number>(
|
||||
isTablet ? extraDaysConfig[layout].tablet : extraDaysConfig[layout].desktop
|
||||
);
|
||||
const bookerLayouts = event?.profile?.bookerLayouts || defaultBookerLayoutSettings;
|
||||
const bookerLayouts = profileBookerLayouts || defaultBookerLayoutSettings;
|
||||
const defaultLayout = isEmbed
|
||||
? validateLayout(embedUiConfig.layout) || bookerLayouts.defaultLayout
|
||||
: bookerLayouts.defaultLayout;
|
||||
|
||||
@@ -203,7 +203,7 @@ export const BookerPlatformWrapper = (
|
||||
event.data.length = props.duration;
|
||||
}
|
||||
|
||||
const bookerLayout = useBookerLayout(event.data);
|
||||
const bookerLayout = useBookerLayout(event.data?.profile?.bookerLayouts);
|
||||
useInitializeBookerStore({
|
||||
...props,
|
||||
teamMemberEmail,
|
||||
|
||||
@@ -47,8 +47,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => {
|
||||
}
|
||||
: clientFetchedEvent;
|
||||
|
||||
const bookerLayout = useBookerLayout(event.data);
|
||||
|
||||
const bookerLayout = useBookerLayout(event.data?.profile?.bookerLayouts);
|
||||
const selectedDate = searchParams?.get("date");
|
||||
const isRedirect = searchParams?.get("redirected") === "true" || false;
|
||||
const fromUserNameRedirected = searchParams?.get("username") || "";
|
||||
|
||||
Reference in new issue
Block a user