diff --git a/.gitignore b/.gitignore index a5da3c9c..53ec8256 100644 --- a/.gitignore +++ b/.gitignore @@ -11,11 +11,11 @@ node_modules # testing coverage /test-results/ -playwright/videos -playwright/screenshots -playwright/artifacts -playwright/results -playwright/reports/* +**/playwright/videos +**/playwright/screenshots +**/playwright/artifacts +**/playwright/results +**/playwright/reports/* # next.js .next/ diff --git a/apps/docs/pages/integrations/embed.mdx b/apps/docs/pages/integrations/embed.mdx new file mode 100644 index 00000000..4503cb3b --- /dev/null +++ b/apps/docs/pages/integrations/embed.mdx @@ -0,0 +1,8 @@ +--- +title: Embed Snippet +--- + +# Embed Snippet + +The Embed Snippet allows your website visitors to book a meeting with you directly from your website. It works by you installing a small Javascript Snippet to your website. +[Mention possiblity of installation through tag managers as well] diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 67fd9c25..b927eb3c 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -19,6 +19,7 @@ import { FormattedNumber, IntlProvider } from "react-intl"; import { asStringOrNull } from "@lib/asStringOrNull"; import { timeZone } from "@lib/clock"; import { BASE_URL } from "@lib/config/constants"; +import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally"; import { useLocale } from "@lib/hooks/useLocale"; import useTheme from "@lib/hooks/useTheme"; import { isBrandingHidden } from "@lib/isBrandingHidden"; @@ -41,13 +42,13 @@ dayjs.extend(customParseFormat); type Props = AvailabilityTeamPageProps | AvailabilityPageProps; -const AvailabilityPage = ({ profile, eventType, workingHours, previousPage }: Props) => { +const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage }: Props) => { const router = useRouter(); const { rescheduleUid } = router.query; const { isReady, Theme } = useTheme(profile.theme); const { t } = useLocale(); const { contracts } = useContracts(); - + useExposePlanGlobally(plan); useEffect(() => { if (eventType.metadata.smartContractAddress) { const eventOwner = eventType.users[0]; diff --git a/apps/web/lib/hooks/useExposePlanGlobally.ts b/apps/web/lib/hooks/useExposePlanGlobally.ts new file mode 100644 index 00000000..ea59dce7 --- /dev/null +++ b/apps/web/lib/hooks/useExposePlanGlobally.ts @@ -0,0 +1,11 @@ +import { useEffect } from "react"; + +import { UserPlan } from "@calcom/prisma/client"; + +export function useExposePlanGlobally(plan: UserPlan) { + // Don't wait for component to mount. Do it ASAP. Delaying it would delay UI Configuration. + if (typeof window !== "undefined") { + // This variable is used by embed-iframe to determine if we should allow UI configuration + window.CalComPlan = plan; + } +} diff --git a/apps/web/pages/[user].tsx b/apps/web/pages/[user].tsx index 05ba5418..6e0358be 100644 --- a/apps/web/pages/[user].tsx +++ b/apps/web/pages/[user].tsx @@ -4,13 +4,14 @@ import { GetServerSidePropsContext } from "next"; import dynamic from "next/dynamic"; import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Toaster } from "react-hot-toast"; import { JSONObject } from "superjson/dist/types"; import { sdkActionManager, useEmbedStyles } from "@calcom/embed-core"; import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally"; import useTheme from "@lib/hooks/useTheme"; import prisma from "@lib/prisma"; import { inferSSRProps } from "@lib/types/inferSSRProps"; @@ -35,7 +36,7 @@ export default function User(props: inferSSRProps) { const eventTypeListItemEmbedStyles = useEmbedStyles("eventTypeListItem"); const query = { ...router.query }; delete query.user; // So it doesn't display in the Link (and make tests fail) - + useExposePlanGlobally("PRO"); const nameOrUsername = user.name || user.username || ""; const [evtsToVerify, setEvtsToVerify] = useState({}); return ( diff --git a/apps/web/pages/[user]/[type].tsx b/apps/web/pages/[user]/[type].tsx index 569b1d1f..9748dfb6 100644 --- a/apps/web/pages/[user]/[type].tsx +++ b/apps/web/pages/[user]/[type].tsx @@ -225,6 +225,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => brandColor: user.brandColor, darkBrandColor: user.darkBrandColor, }, + plan: user.plan, date: dateParam, eventType: eventTypeObject, workingHours, diff --git a/apps/web/pages/team/[slug].tsx b/apps/web/pages/team/[slug].tsx index 56aa697e..653f7620 100644 --- a/apps/web/pages/team/[slug].tsx +++ b/apps/web/pages/team/[slug].tsx @@ -7,6 +7,7 @@ import React from "react"; import Button from "@calcom/ui/Button"; import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar"; +import { useExposePlanGlobally } from "@lib/hooks/useExposePlanGlobally"; import { useLocale } from "@lib/hooks/useLocale"; import useTheme from "@lib/hooks/useTheme"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; @@ -27,7 +28,7 @@ function TeamPage({ team }: TeamPageProps) { const { isReady, Theme } = useTheme(); const showMembers = useToggleQuery("members"); const { t } = useLocale(); - + useExposePlanGlobally("PRO"); const eventTypes = (