From 422ef2f5b86b3859768ce591a56721fc0836471a Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:55:25 +0200 Subject: [PATCH] chore: add cal.com logo to platform booker embed (#18269) * chore: add cal.com logo to platform booker embed * fixup! chore: add cal.com logo to platform booker embed --------- Co-authored-by: Rajiv Sahal --- packages/features/bookings/Booker/Booker.tsx | 10 ++++++---- packages/features/bookings/Booker/types.ts | 1 + packages/features/ee/components/PoweredBy.tsx | 17 ++++++++++++----- .../atoms/booker/BookerPlatformWrapper.tsx | 1 + .../platform/atoms/booker/BookerWebWrapper.tsx | 1 + 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/features/bookings/Booker/Booker.tsx b/packages/features/bookings/Booker/Booker.tsx index a135452f13..523ca891ab 100644 --- a/packages/features/bookings/Booker/Booker.tsx +++ b/packages/features/bookings/Booker/Booker.tsx @@ -6,6 +6,7 @@ import StickyBox from "react-sticky-box"; import { shallow } from "zustand/shallow"; import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager"; +import { useIsPlatformBookerEmbed } from "@calcom/atoms/monorepo"; import dayjs from "@calcom/dayjs"; import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param"; import { useNonEmptyScheduleDays } from "@calcom/features/schedules"; @@ -31,7 +32,7 @@ import { useBookerStore } from "./store"; import type { BookerProps, WrappedBookerProps } from "./types"; const loadFramerFeatures = () => import("./framer-features").then((res) => res.default); -const PoweredBy = dynamic(() => import("@calcom/ee/components/PoweredBy")); +const PoweredBy = dynamic(() => import("@calcom/ee/components/PoweredBy").then((mod) => mod.default)); const UnpublishedEntity = dynamic(() => import("@calcom/ui/components/unpublished-entity/UnpublishedEntity").then((mod) => mod.UnpublishedEntity) ); @@ -68,9 +69,10 @@ const BookerComponent = ({ customClassNames, areInstantMeetingParametersSet = false, userLocale, + hasValidLicense, }: BookerProps & WrappedBookerProps) => { const { t } = useLocale(); - + const isPlatformBookerEmbed = useIsPlatformBookerEmbed(); const [bookerState, setBookerState] = useBookerStore((state) => [state.state, state.setState], shallow); const selectedDate = useBookerStore((state) => state.selectedDate); const { @@ -462,7 +464,7 @@ const BookerComponent = ({ /> )} - {!hideBranding && !isPlatform && ( + {!hideBranding && (!isPlatform || isPlatformBookerEmbed) && ( - + )} diff --git a/packages/features/bookings/Booker/types.ts b/packages/features/bookings/Booker/types.ts index 7f2d3c4157..8e59840851 100644 --- a/packages/features/bookings/Booker/types.ts +++ b/packages/features/bookings/Booker/types.ts @@ -92,6 +92,7 @@ export interface BookerProps { crmAppSlug?: string | null; areInstantMeetingParametersSet?: boolean | null; userLocale?: string | null; + hasValidLicense?: boolean; } export type WrappedBookerPropsMain = { diff --git a/packages/features/ee/components/PoweredBy.tsx b/packages/features/ee/components/PoweredBy.tsx index 89379fe044..6e6d3bfe34 100644 --- a/packages/features/ee/components/PoweredBy.tsx +++ b/packages/features/ee/components/PoweredBy.tsx @@ -1,15 +1,18 @@ -import { useSession } from "next-auth/react"; import Link from "next/link"; import { useIsEmbed } from "@calcom/embed-core/embed-iframe"; import { APP_NAME, POWERED_BY_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -const PoweredByCal = ({ logoOnly }: { logoOnly?: boolean }) => { +const PoweredByCal = ({ + logoOnly, + hasValidLicense, +}: { + logoOnly?: boolean; + hasValidLicense?: boolean | null; +}) => { const { t } = useLocale(); - const session = useSession(); const isEmbed = useIsEmbed(); - const hasValidLicense = session.data ? session.data.hasValidLicense : null; return (
@@ -17,7 +20,11 @@ const PoweredByCal = ({ logoOnly }: { logoOnly?: boolean }) => { {!logoOnly && <>{t("powered_by")} } {APP_NAME === "Cal.com" || !hasValidLicense ? ( <> - Cal.com Logo + Cal.com Logo ) : ( {APP_NAME} diff --git a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx index 1195005eb7..386789d5d9 100644 --- a/packages/platform/atoms/booker/BookerPlatformWrapper.tsx +++ b/packages/platform/atoms/booker/BookerPlatformWrapper.tsx @@ -494,6 +494,7 @@ export const BookerPlatformWrapper = ( bookerLayout={bookerLayout} verifyCode={undefined} isPlatform + hasValidLicense={true} /> ); diff --git a/packages/platform/atoms/booker/BookerWebWrapper.tsx b/packages/platform/atoms/booker/BookerWebWrapper.tsx index 3983b048b4..88eb7acc68 100644 --- a/packages/platform/atoms/booker/BookerWebWrapper.tsx +++ b/packages/platform/atoms/booker/BookerWebWrapper.tsx @@ -216,6 +216,7 @@ export const BookerWebWrapper = (props: BookerWebWrapperAtomProps) => { rescheduledBy={rescheduledBy} bookingUid={bookingUid} hasSession={hasSession} + hasValidLicense={session?.hasValidLicense ?? false} extraOptions={routerQuery} bookings={bookings} calendars={calendars}