diff --git a/apps/web/components/Embed.tsx b/apps/web/components/Embed.tsx index d194306793..e01b846121 100644 --- a/apps/web/components/Embed.tsx +++ b/apps/web/components/Embed.tsx @@ -1,5 +1,6 @@ import { Collapsible, CollapsibleContent } from "@radix-ui/react-collapsible"; import classNames from "classnames"; +import { useSession } from "next-auth/react"; import type { TFunction } from "next-i18next"; import type { NextRouter } from "next/router"; import { useRouter } from "next/router"; @@ -7,12 +8,27 @@ import type { MutableRefObject, RefObject } from "react"; import { createRef, forwardRef, useRef, useState } from "react"; import type { ControlProps } from "react-select"; import { components } from "react-select"; +import { shallow } from "zustand/shallow"; +import type { Dayjs } from "@calcom/dayjs"; +import dayjs from "@calcom/dayjs"; +import { AvailableTimes } from "@calcom/features/bookings"; +import { useInitializeBookerStore, useBookerStore } from "@calcom/features/bookings/Booker/store"; import type { BookerLayout } from "@calcom/features/bookings/Booker/types"; +import { useEvent, useScheduleForEvent } from "@calcom/features/bookings/Booker/utils/event"; +import { useTimePreferences } from "@calcom/features/bookings/lib/timePreferences"; +import DatePicker from "@calcom/features/calendars/DatePicker"; import { useFlagMap } from "@calcom/features/flags/context/provider"; +import { useNonEmptyScheduleDays } from "@calcom/features/schedules"; +import { useSlotsForDate } from "@calcom/features/schedules/lib/use-schedule/useSlotsForDate"; +import { CAL_URL } from "@calcom/lib/constants"; import { APP_NAME, EMBED_LIB_URL, IS_SELF_HOSTED, WEBAPP_URL } from "@calcom/lib/constants"; +import { weekdayToWeekIndex } from "@calcom/lib/date-fns"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { BookerLayouts } from "@calcom/prisma/zod-utils"; +import type { RouterOutputs } from "@calcom/trpc/react"; +import { trpc } from "@calcom/trpc/react"; +import { TimezoneSelect } from "@calcom/ui"; import { Button, Dialog, @@ -28,9 +44,10 @@ import { ColorPicker, Select, } from "@calcom/ui"; -import { Code, Trello, Sun, ArrowLeft } from "@calcom/ui/components/icon"; +import { Code, Trello, Sun, ArrowLeft, ArrowDown, ArrowUp } from "@calcom/ui/components/icon"; -type EmbedType = "inline" | "floating-popup" | "element-click"; +type EventType = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"] | undefined; +type EmbedType = "inline" | "floating-popup" | "element-click" | "email"; type EmbedFramework = "react" | "HTML"; const enum Theme { @@ -61,7 +78,7 @@ type PreviewState = { hideEventTypeDetails: boolean; layout: BookerLayouts; }; -const queryParamsForDialog = ["embedType", "embedTabName", "embedUrl"]; +const queryParamsForDialog = ["embedType", "embedTabName", "embedUrl", "eventId"]; const getDimension = (dimension: string) => { if (dimension.match(/^\d+$/)) { @@ -90,6 +107,12 @@ const removeQueryParams = (router: NextRouter, queryParams: string[]) => { router.push(`${router.asPath.split("?")[0]}?${params.toString()}`); }; +const getQueryParam = (queryParam: string) => { + const params = new URLSearchParams(window.location.search); + + return params.get(queryParam); +}; + /** * It allows us to show code with certain reusable blocks indented according to the block variable placement * So, if you add a variable ${abc} with indentation of 4 spaces, it will automatically indent all newlines in `abc` with the same indent before constructing the final string @@ -317,6 +340,7 @@ const getEmbedTypeSpecificString = ({ if (!frameworkCodes) { throw new Error(`No code available for the framework:${embedFramework}`); } + if (embedType === "email") return ""; let uiInstructionStringArg: { apiName: string; theme: PreviewState["theme"]; @@ -551,6 +575,32 @@ const embeds = (t: TFunction) => ), }, + { + title: t("email_embed"), + subtitle: t("add_times_to_your_email"), + type: "email", + illustration: ( + + + + + + + + + + + ), + }, ]; })(); @@ -706,7 +756,7 @@ const ChooseEmbedTypesDialogContent = () => {
{embeds(t).map((embed, index) => (