Skip to content

Commit

Permalink
feat: New Booker: Disable dialog form in mobile in embed (calcom#9748)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara authored Jun 23, 2023
1 parent 8718905 commit 6a976f5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/features/bookings/Booker/Booker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { BookerSection } from "./components/Section";
import { Away, NotFound } from "./components/Unavailable";
import { extraDaysConfig, fadeInLeft, getBookerSizeClassNames, useBookerResizeAnimation } from "./config";
import { useBookerStore, useInitializeBookerStore } from "./store";
import type { BookerProps } from "./types";
import type { BookerLayout, BookerProps } from "./types";
import { useEvent } from "./utils/event";
import { validateLayout } from "./utils/layout";
import { getQueryParam } from "./utils/query-param";
Expand Down Expand Up @@ -114,6 +114,21 @@ const BookerComponent = ({
return <NotFound />;
}

// In Embed, a Dialog doesn't look good, we disable it intentionally for the layouts that support showing Form without Dialog(i.e. no-dialog Form)
const shouldShowFormInDialogMap: Record<BookerLayout, boolean> = {
// mobile supports showing the Form without Dialog
mobile: !isEmbed,
// We don't show Dialog in month_view currently. Can be easily toggled though as it supports no-dialog Form
month_view: false,
// week_view doesn't support no-dialog Form
// When it's supported, disable it for embed
week_view: true,
// column_view doesn't support no-dialog Form
// When it's supported, disable it for embed
column_view: true,
};

const shouldShowFormInDialog = shouldShowFormInDialogMap[layout];
return (
<>
{event.data ? <BookingPageTagManager eventType={event.data} /> : null}
Expand Down Expand Up @@ -174,7 +189,7 @@ const BookerComponent = ({
area="main"
className="border-subtle sticky top-0 ml-[-1px] h-full p-6 md:w-[var(--booker-main-width)] md:border-l"
{...fadeInLeft}
visible={bookerState === "booking" && layout === BookerLayouts.MONTH_VIEW}>
visible={bookerState === "booking" && !shouldShowFormInDialog}>
<BookEventForm onCancel={() => setSelectedTimeslot(null)} />
</BookerSection>

Expand Down Expand Up @@ -232,7 +247,7 @@ const BookerComponent = ({
</div>

<BookFormAsModal
visible={layout !== BookerLayouts.MONTH_VIEW && bookerState === "booking"}
visible={bookerState === "booking" && shouldShowFormInDialog}
onCancel={() => setSelectedTimeslot(null)}
/>
</>
Expand Down

0 comments on commit 6a976f5

Please sign in to comment.