Scheduling infrastructure for absolutely everyone.
Change location of booking (#2658)
Carina Wollendorfer7b01bae8297a
diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsxindex 07ceb2ee44e..b0ffea2ac6a 100644--- a/apps/web/components/booking/BookingListItem.tsx+++ b/apps/web/components/booking/BookingListItem.tsx@@ -2,6 +2,7 @@ import {BanIcon,CheckIcon,ClockIcon,+ LocationMarkerIcon,PaperAirplaneIcon,PencilAltIcon,XIcon,@@ -16,6 +17,7 @@ import { Frequency as RRuleFrequency } from "rrule";import classNames from "@calcom/lib/classNames";import { useLocale } from "@calcom/lib/hooks/useLocale";+import showToast from "@calcom/lib/notification";import Button from "@calcom/ui/Button";import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog";import { Tooltip } from "@calcom/ui/Tooltip";@@ -23,9 +25,11 @@ import { TextArea } from "@calcom/ui/form/fields";import { HttpError } from "@lib/core/http/error";import useMeQuery from "@lib/hooks/useMeQuery";+import { LocationType } from "@lib/location";import { parseRecurringDates } from "@lib/parseDate";import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc";+import { EditLocationDialog } from "@components/dialog/EditLocationDialog";import { RescheduleDialog } from "@components/dialog/RescheduleDialog";import TableActions, { ActionType } from "@components/ui/TableActions";@@ -72,6 +76,7 @@ function BookingListItem(booking: BookingItemProps) {if (!res.ok) {throw new HttpError({ statusCode: res.status });}+ setRejectionDialogIsOpen(false);},{async onSettled() {@@ -89,8 +94,7 @@ function BookingListItem(booking: BookingItemProps) {booking.listingStatus === "upcoming" && booking.recurringEventId !== null? t("reject_all"): t("reject"),- onClick: (e) => {- e.stopPropagation();+ onClick: () => {setRejectionDialogIsOpen(true);},icon: BanIcon,@@ -102,8 +106,7 @@ function BookingListItem(booking: BookingItemProps) {booking.listingStatus === "upcoming" && booking.recurringEventId !== null? t("confirm_all"): t("confirm"),- onClick: (e) => {- e.stopPropagation();+ onClick: () => {mutation.mutate(true);},icon: CheckIcon,@@ -120,25 +123,33 @@ function BookingListItem(booking: BookingItemProps) {icon: XIcon,},{- id: "reschedule",- label: t("reschedule"),- icon: ClockIcon,+ id: "edit_booking",+ label: t("edit_booking"),+ icon: PencilAltIcon,actions: [{- id: "edit",- icon: PencilAltIcon,- label: t("edit_booking"),+ id: "reschedule",+ icon: ClockIcon,+ label: t("reschedule_booking"),href: `/reschedule/${booking.uid}`,},{id: "reschedule_request",- icon: ClockIcon,+ icon: PaperAirplaneIcon,+ iconClassName: "rotate-45 w-[18px] -ml-[2px]",label: t("send_reschedule_request"),- onClick: (e) => {- e.stopPropagation();+ onClick: () => {setIsOpenRescheduleDialog(true);},},+ {+ id: "change_location",+ label: t("edit_location"),+ onClick: () => {+ setIsOpenLocationDialog(true);+ },+ icon: LocationMarkerIcon,+ },],},];@@ -154,6 +165,26 @@ function BookingListItem(booking: BookingItemProps) {const startTime = dayjs(booking.startTime).format(isUpcoming ? "ddd, D MMM" : "D MMMM YYYY");const [isOpenRescheduleDialog, setIsOpenRescheduleDialog] = useState(false);+ const [isOpenSetLocationDialog, setIsOpenLocationDialog] = useState(false);+ const setLocationMutation = trpc.useMutation("viewer.bookings.editLocation", {+ onSuccess: () => {+ showToast(t("location_updated"), "success");+ setIsOpenLocationDialog(false);+ utils.invalidateQueries("viewer.bookings");+ },+ });++ const saveLocation = (newLocationType: LocationType, details: { [key: string]: string }) => {+ let newLocation = newLocationType as string;+ if (+ newLocationType === LocationType.InPerson ||+ newLocationType === LocationType.Link ||+ newLocationType === LocationType.UserPhone+ ) {+ newLocation = details[Object.keys(details)[0]];+ }+ setLocationMutation.mutate({ bookingId: booking.id, newLocation });+ };// Calculate the booking date(s)let recurringStrings: string[] = [];@@ -168,6 +199,28 @@ function BookingListItem(booking: BookingItemProps) {);}+ const onClick = () => {+ router.push({+ pathname: "/success",+ query: {+ date: booking.startTime,+ type: booking.eventType.id,+ eventSlug: booking.eventType.slug,+ user: user?.username || "",+ name: booking.attendees[0].name,+ email: booking.attendees[0].email,+ location: booking.location+ ? booking.location.includes("integration")+ ? (t("web_conferencing_details_to_follow") as string)+ : booking.location+ : "",+ eventName: booking.eventType.eventName || "",+ bookingId: booking.id,+ recur: booking.recurringEventId,+ reschedule: booking.confirmed,+ },+ });+ };return (<><RescheduleDialog@@ -175,6 +228,12 @@ function BookingListItem(booking: BookingItemProps) {setIsOpenDialog={setIsOpenRescheduleDialog}bookingUId={booking.uid}/>+ <EditLocationDialog+ booking={booking}+ saveLocation={saveLocation}+ isOpenDialog={isOpenSetLocationDialog}+ setShowLocationModal={setIsOpenLocationDialog}+ />{/* NOTE: Should refactor this dialog component as is being rendered multiple times */}<Dialog open={rejectionDialogIsOpen} onOpenChange={setRejectionDialogIsOpen}>@@ -209,115 +268,103 @@ function BookingListItem(booking: BookingItemProps) {</DialogContent></Dialog>- <tr- className="flex cursor-pointer hover:bg-neutral-50"- onClick={() =>- router.push({- pathname: "/success",- query: {- date: booking.startTime,- type: booking.eventType.id,- eventSlug: booking.eventType.slug,- user: user?.username || "",- name: booking.attendees[0].name,- email: booking.attendees[0].email,- location: booking.location- ? booking.location.includes("integration")- ? (t("web_conferencing_details_to_follow") as string)- : booking.location- : "",- eventName: booking.eventType.eventName || "",- bookingId: booking.id,- recur: booking.recurringEventId,- reschedule: booking.confirmed,- status: booking.listingStatus,- },- })- }>- <td className="hidden whitespace-nowrap py-4 align-top ltr:pl-6 rtl:pr-6 sm:table-cell sm:w-56">- <div className="text-sm leading-6 text-gray-900">{startTime}</div>- <div className="text-sm text-gray-500">- {dayjs(booking.startTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")} -{" "}- {dayjs(booking.endTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")}- </div>- <div className="text-sm text-gray-400">- {booking.recurringCount &&- booking.eventType?.recurringEvent?.freq &&- booking.listingStatus === "upcoming" && (- <div className="underline decoration-gray-400 decoration-dashed underline-offset-2">- <div className="flex">- <Tooltip- content={recurringStrings.map((aDate, key) => (- <p key={key}>{aDate}</p>- ))}>- <p className="text-gray-600 dark:text-white">- <RefreshIcon className="mr-1 -mt-1 inline-block h-4 w-4 text-gray-400" />- {`${t("every_for_freq", {- freq: t(+ <tr className="flex hover:bg-neutral-50">+ <td+ className="hidden whitespace-nowrap align-top ltr:pl-6 rtl:pr-6 sm:table-cell sm:w-56"+ onClick={onClick}>+ <div className="cursor-pointer py-4">+ <div className="text-sm leading-6 text-gray-900">{startTime}</div>+ <div className="text-sm text-gray-500">+ {dayjs(booking.startTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")} -{" "}+ {dayjs(booking.endTime).format(user && user.timeFormat === 12 ? "h:mma" : "HH:mm")}+ </div>+ <div className="text-sm text-gray-400">+ {booking.recurringCount &&+ booking.eventType?.recurringEvent?.freq &&+ booking.listingStatus === "upcoming" && (+ <div className="underline decoration-gray-400 decoration-dashed underline-offset-2">+ <div className="flex">+ <Tooltip+ content={recurringStrings.map((aDate, key) => (+ <p key={key}>{aDate}</p>+ ))}>+ <p className="text-gray-600 dark:text-white">+ <RefreshIcon className="mr-1 -mt-1 inline-block h-4 w-4 text-gray-400" />+ {`${t("every_for_freq", {+ freq: t(+ `${RRuleFrequency[booking.eventType.recurringEvent.freq]+ .toString()+ .toLowerCase()}`+ ),+ })} ${booking.recurringCount} ${t(`${RRuleFrequency[booking.eventType.recurringEvent.freq].toString()- .toLowerCase()}`- ),- })} ${booking.recurringCount} ${t(- `${RRuleFrequency[booking.eventType.recurringEvent.freq].toString().toLowerCase()}`,- { count: booking.recurringCount }- )}`}- </p>- </Tooltip>+ .toLowerCase()}`,+ { count: booking.recurringCount }+ )}`}+ </p>+ </Tooltip>+ </div></div>- </div>- )}+ )}+ </div></div></td>- <td className={"flex-1 py-4 ltr:pl-4 rtl:pr-4" + (booking.rejected ? " line-through" : "")}>- <div className="sm:hidden">- {!booking.confirmed && !booking.rejected && (- <Tag className="mb-2 ltr:mr-2 rtl:ml-2">{t("unconfirmed")}</Tag>- )}- {!!booking?.eventType?.price && !booking.paid && (- <Tag className="mb-2 ltr:mr-2 rtl:ml-2">Pending payment</Tag>- )}- <div className="text-sm font-medium text-gray-900">- {startTime}:{" "}- <small className="text-sm text-gray-500">- {dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}- </small>+ <td+ className={"flex-1 ltr:pl-4 rtl:pr-4" + (booking.rejected ? " line-through" : "")}+ onClick={onClick}>+ <div className="cursor-pointer py-4">+ <div className="sm:hidden">+ {!booking.confirmed && !booking.rejected && (+ <Tag className="mb-2 ltr:mr-2 rtl:ml-2">{t("unconfirmed")}</Tag>+ )}+ {!!booking?.eventType?.price && !booking.paid && (+ <Tag className="mb-2 ltr:mr-2 rtl:ml-2">Pending payment</Tag>+ )}+ <div className="text-sm font-medium text-gray-900">+ {startTime}:{" "}+ <small className="text-sm text-gray-500">+ {dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}+ </small>+ </div></div>- </div>- <div- title={booking.title}- className={classNames(- "max-w-56 truncate text-sm font-medium leading-6 text-neutral-900 md:max-w-max",- isCancelled ? "line-through" : ""- )}>- {booking.eventType?.team && <strong>{booking.eventType.team.name}: </strong>}- {booking.title}- {!!booking?.eventType?.price && !booking.paid && (- <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">Pending payment</Tag>+ <div+ title={booking.title}+ className={classNames(+ "max-w-56 truncate text-sm font-medium leading-6 text-neutral-900 md:max-w-max",+ isCancelled ? "line-through" : ""+ )}>+ {booking.eventType?.team && <strong>{booking.eventType.team.name}: </strong>}+ {booking.title}+ {!!booking?.eventType?.price && !booking.paid && (+ <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">Pending payment</Tag>+ )}+ {!booking.confirmed && !booking.rejected && (+ <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">{t("unconfirmed")}</Tag>+ )}+ </div>+ {booking.description && (+ <div+ className="max-w-52 md:max-w-96 truncate text-sm text-gray-500"+ title={booking.description}>+ "{booking.description}"+ </div>+ )}++ {booking.attendees.length !== 0 && (+ <a+ className="text-sm text-gray-900 hover:text-blue-500"+ href={"mailto:" + booking.attendees[0].email}+ onClick={(e) => e.stopPropagation()}>+ {booking.attendees[0].email}+ </a>)}- {!booking.confirmed && !booking.rejected && (- <Tag className="hidden ltr:ml-2 rtl:mr-2 sm:inline-flex">{t("unconfirmed")}</Tag>+ {isCancelled && booking.rescheduled && (+ <div className="mt-2 inline-block text-left text-sm md:hidden">+ <RequestSentMessage />+ </div>)}</div>- {booking.description && (- <div className="max-w-52 md:max-w-96 truncate text-sm text-gray-500" title={booking.description}>- "{booking.description}"- </div>- )}-- {booking.attendees.length !== 0 && (- <a- className="text-sm text-gray-900 hover:text-blue-500"- href={"mailto:" + booking.attendees[0].email}- onClick={(e) => e.stopPropagation()}>- {booking.attendees[0].email}- </a>- )}- {isCancelled && booking.rescheduled && (- <div className="mt-2 inline-block text-left text-sm md:hidden">- <RequestSentMessage />- </div>- )}</td><td className="whitespace-nowrap py-4 text-right text-sm font-medium ltr:pr-4 rtl:pl-4">diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsxindex 4a23427d270..fcea4866b70 100644--- a/apps/web/components/booking/pages/AvailabilityPage.tsx+++ b/apps/web/components/booking/pages/AvailabilityPage.tsx@@ -68,6 +68,8 @@ export const locationKeyToString = (location: LocationObject, t: TFunction) => {case LocationType.Link:return location.link || "Link"; // If disabled link won't exist on the objectcase LocationType.Phone:+ return t("your_number");+ case LocationType.UserPhone:return t("phone_call");case LocationType.GoogleMeet:return "Google Meet";@@ -370,7 +372,9 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPagereturn (<span key={el.type}>{locationKeyToString(el, t)}{" "}- {arr.length - 1 !== i && <span className="font-light"> or </span>}+ {arr.length - 1 !== i && (+ <span className="font-light"> {t("or_lowercase")} </span>+ )}</span>);})}@@ -424,7 +428,7 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage{previousPage === `${WEBAPP_URL}/${profile.slug}` && (<div className="flex h-full flex-col justify-end"><ArrowLeftIcon- className="h-4 w-4 text-black transition-opacity hover:cursor-pointer dark:text-white"+ className="h-4 w-4 text-black transition-opacity hover:cursor-pointer dark:text-white"onClick={() => router.back()}/><p className="sr-only">Go Back</p>diff --git a/apps/web/components/dialog/EditLocationDialog.tsx b/apps/web/components/dialog/EditLocationDialog.tsxnew file mode 100644index 00000000000..63bfb909e5f--- /dev/null+++ b/apps/web/components/dialog/EditLocationDialog.tsx@@ -0,0 +1,335 @@+import { LocationMarkerIcon } from "@heroicons/react/solid";+import { zodResolver } from "@hookform/resolvers/zod";+import { isValidPhoneNumber } from "libphonenumber-js";+import dynamic from "next/dynamic";+import { useEffect } from "react";+import { Controller, useForm, useWatch } from "react-hook-form";+import { z } from "zod";++import { useLocale } from "@calcom/lib/hooks/useLocale";+import { Button } from "@calcom/ui";+import { Dialog, DialogContent } from "@calcom/ui/Dialog";+import { Form } from "@calcom/ui/form/fields";++import { QueryCell } from "@lib/QueryCell";+import { linkValueToString } from "@lib/linkValueToString";+import { LocationType } from "@lib/location";+import { LocationOptionsToString } from "@lib/locationOptions";+import { inferQueryOutput, trpc } from "@lib/trpc";++import CheckboxField from "@components/ui/form/CheckboxField";+import type PhoneInputType from "@components/ui/form/PhoneInput";+import Select from "@components/ui/form/Select";++const PhoneInput = dynamic(+ () => import("@components/ui/form/PhoneInput")+) as unknown as typeof PhoneInputType;++type BookingItem = inferQueryOutput<"viewer.bookings">["bookings"][number];++type OptionTypeBase = {+ label: string;+ value: LocationType;+ disabled?: boolean;+};++type LocationFormValues = {+ locationType: LocationType;+ locationAddress?: string;+ locationLink?: string;+ locationPhoneNumber?: string;+ displayLocationPublicly?: boolean;+};+interface ISetLocationDialog {+ saveLocation: (newLocationType: LocationType, details: { [key: string]: string }) => void;+ selection?: OptionTypeBase;+ booking?: BookingItem;+ defaultValues?: {+ type: LocationType;+ address?: string | undefined;+ link?: string | undefined;+ hostPhoneNumber?: string | undefined;+ displayLocationPublicly?: boolean | undefined;+ }[];+ setShowLocationModal: React.Dispatch<React.SetStateAction<boolean>>;+ isOpenDialog: boolean;+ setSelectedLocation?: (param: OptionTypeBase | undefined) => void;+}++export const EditLocationDialog = (props: ISetLocationDialog) => {+ const {+ saveLocation,+ selection,+ booking,+ setShowLocationModal,+ isOpenDialog,+ defaultValues,+ setSelectedLocation,+ } = props;+ const { t } = useLocale();+ const locationsQuery = trpc.useQuery(["viewer.locationOptions"]);++ useEffect(() => {+ if (selection) {+ locationFormMethods.setValue("locationType", selection?.value);+ }+ }, [selection]);++ const locationFormSchema = z.object({+ locationType: z.string(),+ locationAddress: z.string().optional(),+ locationLink: z.string().url().optional(),+ displayLocationPublicly: z.boolean().optional(),+ locationPhoneNumber: z+ .string()+ .refine((val) => isValidPhoneNumber(val))+ .optional(),+ });++ const locationFormMethods = useForm<LocationFormValues>({+ mode: "onSubmit",+ resolver: zodResolver(locationFormSchema),+ });++ const selectedLocation = useWatch({+ control: locationFormMethods.control,+ name: "locationType",+ });++ const LocationOptions =+ selectedLocation === LocationType.InPerson ? (+ <>+ <div>+ <label htmlFor="address" className="block text-sm font-medium text-gray-700">+ {t("set_address_place")}+ </label>+ <div className="mt-1">+ <input+ type="text"+ {...locationFormMethods.register("locationAddress")}+ id="address"+ required+ className="block w-full rounded-sm border-gray-300 text-sm"+ defaultValue={+ defaultValues+ ? defaultValues.find(+ (location: { type: LocationType }) => location.type === LocationType.InPerson+ )?.address+ : undefined+ }+ />+ </div>+ {!booking && (+ <div className="mt-3">+ <Controller+ name="displayLocationPublicly"+ control={locationFormMethods.control}+ render={() => (+ <CheckboxField+ defaultChecked={+ defaultValues+ ? defaultValues.find((location) => location.type === LocationType.InPerson)+ ?.displayLocationPublicly+ : undefined+ }+ description={t("display_location_label")}+ onChange={(e) =>+ locationFormMethods.setValue("displayLocationPublicly", e.target.checked)+ }+ infomationIconText={t("display_location_info_badge")}></CheckboxField>+ )}+ />+ </div>+ )}+ </div>+ </>+ ) : selectedLocation === LocationType.Link ? (+ <div>+ <label htmlFor="link" className="block text-sm font-medium text-gray-700">+ {t("set_link_meeting")}+ </label>+ <div className="mt-1">+ <input+ type="text"+ {...locationFormMethods.register("locationLink")}+ id="link"+ required+ className="block w-full rounded-sm border-gray-300 sm:text-sm"+ defaultValue={+ defaultValues+ ? defaultValues.find(+ (location: { type: LocationType }) => location.type === LocationType.Link+ )?.link+ : undefined+ }+ />+ {locationFormMethods.formState.errors.locationLink && (+ <p className="mt-1 text-sm text-red-500">{t("url_start_with_https")}</p>+ )}+ </div>+ {!booking && (+ <div className="mt-3">+ <Controller+ name="displayLocationPublicly"+ control={locationFormMethods.control}+ render={() => (+ <CheckboxField+ description={t("display_location_label")}+ defaultChecked={+ defaultValues+ ? defaultValues.find((location) => location.type === LocationType.Link)+ ?.displayLocationPublicly+ : undefined+ }+ onChange={(e) => locationFormMethods.setValue("displayLocationPublicly", e.target.checked)}+ infomationIconText={t("display_location_info_badge")}></CheckboxField>+ )}+ />+ </div>+ )}+ </div>+ ) : selectedLocation === LocationType.UserPhone ? (+ <div>+ <label htmlFor="phonenumber" className="block text-sm font-medium text-gray-700">+ {t("set_your_phone_number")}+ {locationFormMethods.formState?.errors?.locationPhoneNumber?.message}+ </label>+ <div className="mt-1">+ <PhoneInput<LocationFormValues>+ control={locationFormMethods.control}+ name="locationPhoneNumber"+ required+ id="locationPhoneNumber"+ placeholder={t("host_phone_number")}+ defaultValue={+ defaultValues+ ? defaultValues.find(+ (location: { type: LocationType }) => location.type === LocationType.UserPhone+ )?.hostPhoneNumber+ : undefined+ }+ />+ {locationFormMethods.formState.errors.locationPhoneNumber && (+ <p className="mt-1 text-sm text-red-500">Invalid input</p>+ )}+ </div>+ </div>+ ) : (+ <p className="text-sm">{LocationOptionsToString(selectedLocation, t)}</p>+ );++ return (+ <Dialog open={isOpenDialog}>+ <DialogContent asChild>+ <div className="inline-block transform rounded-sm bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6 sm:align-middle">+ <div className="mb-4 sm:flex sm:items-start">+ <div className="bg-secondary-100 mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full sm:mx-0 sm:h-10 sm:w-10">+ <LocationMarkerIcon className="text-primary-600 h-6 w-6" />+ </div>+ <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">+ <h3 className="text-lg font-medium leading-6 text-gray-900" id="modal-title">+ {t("edit_location")}+ </h3>+ {!booking && (+ <p className="text-sm text-gray-400">{t("this_input_will_shown_booking_this_event")}</p>+ )}+ </div>+ <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left"></div>+ </div>+ {booking && (+ <>+ <p className="mt-6 mb-2 ml-1 text-sm font-bold text-black">{t("current_location")}:</p>+ <p className="mb-2 ml-1 text-sm text-black">{linkValueToString(booking.location, t)}</p>+ </>+ )}+ <Form+ form={locationFormMethods}+ handleSubmit={async (values) => {+ const { locationType: newLocation, displayLocationPublicly } = values;++ let details = {};+ if (newLocation === LocationType.InPerson) {+ details = {+ address: values.locationAddress,+ displayLocationPublicly,+ };+ }+ if (newLocation === LocationType.Link) {+ details = { link: values.locationLink, displayLocationPublicly };+ }+ if (newLocation === LocationType.UserPhone) {+ details = { hostPhoneNumber: values.locationPhoneNumber };+ }++ saveLocation(newLocation, details);+ setShowLocationModal(false);+ setSelectedLocation?.(undefined);+ locationFormMethods.unregister([+ "locationType",+ "locationLink",+ "locationAddress",+ "locationPhoneNumber",+ ]);+ }}>+ <QueryCell+ query={locationsQuery}+ success={({ data: locationOptions }) => {+ if (!locationOptions.length) return null;+ return (+ <Controller+ name="locationType"+ control={locationFormMethods.control}+ render={() => (+ <Select+ maxMenuHeight={150}+ name="location"+ defaultValue={selection}+ options={+ booking+ ? locationOptions.filter((location) => location.value !== "phone")+ : locationOptions+ }+ isSearchable={false}+ className="my-4 block w-full min-w-0 flex-1 rounded-sm border border-gray-300 sm:text-sm"+ onChange={(val) => {+ if (val) {+ locationFormMethods.setValue("locationType", val.value);+ locationFormMethods.unregister([+ "locationLink",+ "locationAddress",+ "locationPhoneNumber",+ ]);+ locationFormMethods.clearErrors([+ "locationLink",+ "locationPhoneNumber",+ "locationAddress",+ ]);+ setSelectedLocation?.(val);+ }+ }}+ />+ )}+ />+ );+ }}+ />+ {selectedLocation && LocationOptions}+ <div className="mt-4 flex justify-end space-x-2">+ <Button+ onClick={() => {+ setShowLocationModal(false);+ setSelectedLocation?.(undefined);+ locationFormMethods.unregister("locationType");+ }}+ type="button"+ color="secondary">+ {t("cancel")}+ </Button>+ <Button type="submit">{t("update")}</Button>+ </div>+ </Form>+ </div>+ </DialogContent>+ </Dialog>+ );+};diff --git a/apps/web/components/ui/TableActions.tsx b/apps/web/components/ui/TableActions.tsxindex 4750dcd1ce7..7f6d316b58f 100644--- a/apps/web/components/ui/TableActions.tsx+++ b/apps/web/components/ui/TableActions.tsx@@ -9,6 +9,7 @@ import { SVGComponent } from "@lib/types/SVGComponent";export type ActionType = {id: string;icon?: SVGComponent;+ iconClassName?: string;label: string;disabled?: boolean;color?: "primary" | "secondary";@@ -52,6 +53,7 @@ const DropdownActions = ({className="w-full rounded-none font-normal"href={action.href}StartIcon={action.icon}+ startIconClassName={action.iconClassName}onClick={action.onClick || defaultAction}data-testid={action.id}>{action.label}@@ -81,6 +83,7 @@ const TableActions: FC<Props> = ({ actions }) => {href={action.href}onClick={action.onClick || defaultAction}StartIcon={action.icon}+ startIconClassName={action.iconClassName}{...(action?.actions ? { EndIcon: ChevronDownIcon } : null)}disabled={action.disabled}color={action.color || "secondary"}>diff --git a/apps/web/lib/emails/email-manager.ts b/apps/web/lib/emails/email-manager.tsindex 550dac307cd..163e6d9f8c2 100644--- a/apps/web/lib/emails/email-manager.ts+++ b/apps/web/lib/emails/email-manager.ts@@ -3,6 +3,7 @@ import type { CalendarEvent, Person, RecurringEvent } from "@calcom/types/Calendimport AttendeeAwaitingPaymentEmail from "@lib/emails/templates/attendee-awaiting-payment-email";import AttendeeCancelledEmail from "@lib/emails/templates/attendee-cancelled-email";import AttendeeDeclinedEmail from "@lib/emails/templates/attendee-declined-email";+import AttendeeLocationChangeEmail from "@lib/emails/templates/attendee-location-change-email";import AttendeeRequestEmail from "@lib/emails/templates/attendee-request-email";import AttendeeRequestRescheduledEmail from "@lib/emails/templates/attendee-request-reschedule-email";import AttendeeRescheduledEmail from "@lib/emails/templates/attendee-rescheduled-email";@@ -10,6 +11,7 @@ import AttendeeScheduledEmail from "@lib/emails/templates/attendee-scheduled-emaimport FeedbackEmail, { Feedback } from "@lib/emails/templates/feedback-email";import ForgotPasswordEmail, { PasswordReset } from "@lib/emails/templates/forgot-password-email";import OrganizerCancelledEmail from "@lib/emails/templates/organizer-cancelled-email";+import OrganizerLocationChangeEmail from "@lib/emails/templates/organizer-location-change-email";import OrganizerPaymentRefundFailedEmail from "@lib/emails/templates/organizer-payment-refund-failed-email";import OrganizerRequestEmail from "@lib/emails/templates/organizer-request-email";import OrganizerRequestReminderEmail from "@lib/emails/templates/organizer-request-reminder-email";@@ -268,6 +270,38 @@ export const sendRequestRescheduleEmail = async (await Promise.all(emailsToSend);};+export const sendLocationChangeEmails = async (+ calEvent: CalendarEvent,+ recurringEvent: RecurringEvent = {}+) => {+ const emailsToSend: Promise<unknown>[] = [];++ emailsToSend.push(+ ...calEvent.attendees.map((attendee) => {+ return new Promise((resolve, reject) => {+ try {+ const scheduledEmail = new AttendeeLocationChangeEmail(calEvent, attendee, recurringEvent);+ resolve(scheduledEmail.sendEmail());+ } catch (e) {+ reject(console.error("AttendeeLocationChangeEmail.sendEmail failed", e));+ }+ });+ })+ );++ emailsToSend.push(+ new Promise((resolve, reject) => {+ try {+ const scheduledEmail = new OrganizerLocationChangeEmail(calEvent, recurringEvent);+ resolve(scheduledEmail.sendEmail());+ } catch (e) {+ reject(console.error("OrganizerLocationChangeEmail.sendEmail failed", e));+ }+ })+ );++ await Promise.all(emailsToSend);+};export const sendFeedbackEmail = async (feedback: Feedback) => {await new Promise((resolve, reject) => {try {diff --git a/apps/web/lib/emails/templates/attendee-location-change-email.ts b/apps/web/lib/emails/templates/attendee-location-change-email.tsnew file mode 100644index 00000000000..611ebe269d3--- /dev/null+++ b/apps/web/lib/emails/templates/attendee-location-change-email.ts@@ -0,0 +1,165 @@+import dayjs from "dayjs";+import localizedFormat from "dayjs/plugin/localizedFormat";+import timezone from "dayjs/plugin/timezone";+import toArray from "dayjs/plugin/toArray";+import utc from "dayjs/plugin/utc";++import { getCancelLink } from "@calcom/lib/CalEventParser";++import AttendeeScheduledEmail from "./attendee-scheduled-email";+import {+ emailHead,+ emailSchedulingBodyHeader,+ emailBodyLogo,+ emailScheduledBodyHeaderContent,+ emailSchedulingBodyDivider,+} from "./common";++dayjs.extend(utc);+dayjs.extend(timezone);+dayjs.extend(localizedFormat);+dayjs.extend(toArray);++export default class AttendeeLocationChangeEmail extends AttendeeScheduledEmail {+ protected getNodeMailerPayload(): Record<string, unknown> {+ return {+ icalEvent: {+ filename: "event.ics",+ content: this.getiCalEventAsString(),+ },+ to: `${this.attendee.name} <${this.attendee.email}>`,+ from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`,+ replyTo: this.calEvent.organizer.email,+ subject: `${this.attendee.language.translate("location_changed_event_type_subject", {+ eventType: this.calEvent.type,+ name: this.calEvent.team?.name || this.calEvent.organizer.name,+ date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format(+ "h:mma"+ )}, ${this.attendee.language.translate(+ this.getInviteeStart().format("dddd").toLowerCase()+ )}, ${this.attendee.language.translate(+ this.getInviteeStart().format("MMMM").toLowerCase()+ )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`,+ })}`,+ html: this.getHtmlBody(),+ text: this.getTextBody(),+ };+ }+ protected getTextBody(): string {+ // Only the original attendee can make changes to the event+ // Guests cannot+ if (this.attendee === this.calEvent.attendees[0]) {+ return `+ ${this.attendee.language.translate("event_location_changed")}+ ${this.attendee.language.translate("emailed_you_and_any_other_attendees")}+ ${this.getWhat()}+ ${this.getWhen()}+ ${this.getLocation()}+ ${this.getDescription()}+ ${this.getAdditionalNotes()}+ ${this.attendee.language.translate("need_to_reschedule_or_cancel")}+ ${getCancelLink(this.calEvent)}+ `.replace(/(<([^>]+)>)/gi, "");+ }++ return `+${this.attendee.language.translate("event_location_changed")}+${this.attendee.language.translate("emailed_you_and_any_other_attendees")}+${this.getWhat()}+${this.getWhen()}+${this.getLocation()}+${this.getAdditionalNotes()}+`.replace(/(<([^>]+)>)/gi, "");+ }++ protected getHtmlBody(): string {+ const headerContent = this.attendee.language.translate("location_changed_event_type_subject", {+ eventType: this.calEvent.type,+ name: this.calEvent.team?.name || this.calEvent.organizer.name,+ date: `${this.getInviteeStart().format("h:mma")} - ${this.getInviteeEnd().format(+ "h:mma"+ )}, ${this.attendee.language.translate(+ this.getInviteeStart().format("dddd").toLowerCase()+ )}, ${this.attendee.language.translate(+ this.getInviteeStart().format("MMMM").toLowerCase()+ )} ${this.getInviteeStart().format("D")}, ${this.getInviteeStart().format("YYYY")}`,+ });++ return `+ <!doctype html>+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">+ ${emailHead(headerContent)}+ <body style="word-spacing:normal;background-color:#F5F5F5;">+ <div style="background-color:#F5F5F5;">+ ${emailSchedulingBodyHeader("calendarCircle")}+ ${emailScheduledBodyHeaderContent(+ this.attendee.language.translate("event_location_changed"),+ this.attendee.language.translate("emailed_you_and_any_other_attendees")+ )}+ ${emailSchedulingBodyDivider()}+ <!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->+ <div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">+ <tbody>+ <tr>+ <td style="border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">+ <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->+ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">+ <tbody>+ <tr>+ <td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">+ <div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:1;text-align:left;color:#3E3E3E;">+ ${this.getWhat()}+ ${this.getWhen()}+ ${this.getWho()}+ ${this.getLocation()}+ ${this.getDescription()}+ ${this.getAdditionalNotes()}+ </div>+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ ${emailSchedulingBodyDivider()}+ <!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->+ <div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">+ <tbody>+ <tr>+ <td style="border-bottom:1px solid #E1E1E1;border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">+ <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->+ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">+ <tbody>+ <tr>+ <td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">+ <div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:0px;text-align:left;color:#3E3E3E;">+ ${this.getManageLink()}+ </div>+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ ${emailBodyLogo()}+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </div>+ </body>+ </html>+ `;+ }+}diff --git a/apps/web/lib/emails/templates/organizer-location-change-email.ts b/apps/web/lib/emails/templates/organizer-location-change-email.tsnew file mode 100644index 00000000000..15bb3b6b552--- /dev/null+++ b/apps/web/lib/emails/templates/organizer-location-change-email.ts@@ -0,0 +1,162 @@+import dayjs from "dayjs";+import localizedFormat from "dayjs/plugin/localizedFormat";+import timezone from "dayjs/plugin/timezone";+import toArray from "dayjs/plugin/toArray";+import utc from "dayjs/plugin/utc";++import { getCancelLink } from "@calcom/lib/CalEventParser";++import {+ emailHead,+ emailSchedulingBodyHeader,+ emailBodyLogo,+ emailScheduledBodyHeaderContent,+ emailSchedulingBodyDivider,+} from "./common";+import OrganizerScheduledEmail from "./organizer-scheduled-email";++dayjs.extend(utc);+dayjs.extend(timezone);+dayjs.extend(localizedFormat);+dayjs.extend(toArray);++export default class OrganizerLocationChangeEmail extends OrganizerScheduledEmail {+ protected getNodeMailerPayload(): Record<string, unknown> {+ const toAddresses = [this.calEvent.organizer.email];+ if (this.calEvent.team) {+ this.calEvent.team.members.forEach((member) => {+ const memberAttendee = this.calEvent.attendees.find((attendee) => attendee.name === member);+ if (memberAttendee) {+ toAddresses.push(memberAttendee.email);+ }+ });+ }++ return {+ icalEvent: {+ filename: "event.ics",+ content: this.getiCalEventAsString(),+ },+ from: `Cal.com <${this.getMailerOptions().from}>`,+ to: toAddresses.join(","),+ subject: `${this.calEvent.organizer.language.translate("location_changed_event_type_subject", {+ eventType: this.calEvent.type,+ name: this.calEvent.attendees[0].name,+ date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format(+ "h:mma"+ )}, ${this.calEvent.organizer.language.translate(+ this.getOrganizerStart().format("dddd").toLowerCase()+ )}, ${this.calEvent.organizer.language.translate(+ this.getOrganizerStart().format("MMMM").toLowerCase()+ )} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`,+ })}`,+ html: this.getHtmlBody(),+ text: this.getTextBody(),+ };+ }++ protected getTextBody(): string {+ return `+${this.calEvent.organizer.language.translate("event_location_changed")}+${this.calEvent.organizer.language.translate("emailed_you_and_any_other_attendees")}+${this.getWhat()}+${this.getWhen()}+${this.getLocation()}+${this.getDescription()}+${this.getAdditionalNotes()}+${this.calEvent.organizer.language.translate("need_to_reschedule_or_cancel")}+${getCancelLink(this.calEvent)}+`.replace(/(<([^>]+)>)/gi, "");+ }++ protected getHtmlBody(): string {+ const headerContent = this.calEvent.organizer.language.translate("location_changed_event_type_subject", {+ eventType: this.calEvent.type,+ name: this.calEvent.attendees[0].name,+ date: `${this.getOrganizerStart().format("h:mma")} - ${this.getOrganizerEnd().format(+ "h:mma"+ )}, ${this.calEvent.organizer.language.translate(+ this.getOrganizerStart().format("dddd").toLowerCase()+ )}, ${this.calEvent.organizer.language.translate(+ this.getOrganizerStart().format("MMMM").toLowerCase()+ )} ${this.getOrganizerStart().format("D")}, ${this.getOrganizerStart().format("YYYY")}`,+ });++ return `+ <!doctype html>+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">+ ${emailHead(headerContent)}+ <body style="word-spacing:normal;background-color:#F5F5F5;">+ <div style="background-color:#F5F5F5;">+ ${emailSchedulingBodyHeader("calendarCircle")}+ ${emailScheduledBodyHeaderContent(+ this.calEvent.organizer.language.translate("event_location_changed"),+ this.calEvent.organizer.language.translate("emailed_you_and_any_other_attendees")+ )}+ ${emailSchedulingBodyDivider()}+ <!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->+ <div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">+ <tbody>+ <tr>+ <td style="border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">+ <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->+ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">+ <tbody>+ <tr>+ <td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">+ <div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:1;text-align:left;color:#3E3E3E;">+ ${this.getWhat()}+ ${this.getWhen()}+ ${this.getWho()}+ ${this.getLocation()}+ ${this.getDescription()}+ ${this.getAdditionalNotes()}+ </div>+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ ${emailSchedulingBodyDivider()}+ <!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#FFFFFF" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->+ <div style="background:#FFFFFF;background-color:#FFFFFF;margin:0px auto;max-width:600px;">+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#FFFFFF;background-color:#FFFFFF;width:100%;">+ <tbody>+ <tr>+ <td style="border-bottom:1px solid #E1E1E1;border-left:1px solid #E1E1E1;border-right:1px solid #E1E1E1;direction:ltr;font-size:0px;padding:0px;text-align:center;">+ <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:598px;" ><![endif]-->+ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">+ <tbody>+ <tr>+ <td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">+ <div style="font-family:Roboto, Helvetica, sans-serif;font-size:16px;font-weight:500;line-height:0px;text-align:left;color:#3E3E3E;">+ ${this.getManageLink()}+ </div>+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ ${emailBodyLogo()}+ <!--[if mso | IE]></td></tr></table><![endif]-->+ </div>+ </body>+ </html>+ `;+ }+}diff --git a/apps/web/lib/linkValueToString.ts b/apps/web/lib/linkValueToString.tsnew file mode 100644index 00000000000..777296a4514--- /dev/null+++ b/apps/web/lib/linkValueToString.ts@@ -0,0 +1,41 @@+import { TFunction } from "next-i18next";++import { LocationType } from "./location";++/**+ * Use this function to translate booking location value to a readable string+ * @param linkValue+ * @param translationFunction+ * @returns+ */+export const linkValueToString = (+ linkValue: string | undefined | null,+ translationFunction: TFunction+): string => {+ const t = translationFunction;+ if (!linkValue) {+ return translationFunction("no_location");+ }+ switch (linkValue) {+ case LocationType.InPerson:+ return t("in_person_meeting");+ case LocationType.UserPhone:+ return t("user_phone");+ case LocationType.GoogleMeet:+ return `Google Meet: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Zoom:+ return `Zoom: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Daily:+ return `Cal Video: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Jitsi:+ return `Jitsi: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Huddle01:+ return `Huddle01t: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Tandem:+ return `Tandem: ${t("meeting_url_in_conformation_email")}`;+ case LocationType.Teams:+ return `Teams: ${t("meeting_url_in_conformation_email")}`;+ default:+ return linkValue || "";+ }+};diff --git a/apps/web/lib/locationOptions.tsx b/apps/web/lib/locationOptions.tsxindex c0d3b9d0d6a..c9d96287fba 100644--- a/apps/web/lib/locationOptions.tsx+++ b/apps/web/lib/locationOptions.tsx@@ -2,6 +2,12 @@ import { TFunction } from "next-i18next";import { LocationType } from "./location";+/**+ * Use this function for translating event location to a readable string+ * @param location+ * @param t+ * @returns string+ */export const LocationOptionsToString = (location: string, t: TFunction) => {switch (location) {case LocationType.InPerson:diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsxindex a3c58c4bf7f..0bb44a9b5d1 100644--- a/apps/web/pages/event-types/[type].tsx+++ b/apps/web/pages/event-types/[type].tsx@@ -64,6 +64,7 @@ import Shell from "@components/Shell";import { UpgradeToProDialog } from "@components/UpgradeToProDialog";import { AvailabilitySelectSkeletonLoader } from "@components/availability/SkeletonLoader";import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent";+import { EditLocationDialog } from "@components/dialog/EditLocationDialog";import RecurringEventController from "@components/eventtype/RecurringEventController";import CustomInputTypeForm from "@components/pages/eventtypes/CustomInputTypeForm";import Badge from "@components/ui/Badge";@@ -72,7 +73,6 @@ import CheckboxField from "@components/ui/form/CheckboxField";import CheckedSelect from "@components/ui/form/CheckedSelect";import { DateRangePicker } from "@components/ui/form/DateRangePicker";import MinutesField from "@components/ui/form/MinutesField";-import PhoneInput from "@components/ui/form/PhoneInput";import Select from "@components/ui/form/Select";import * as RadioArea from "@components/ui/form/radio-area";import WebhookListContainer from "@components/webhook/WebhookListContainer";@@ -179,7 +179,7 @@ const SuccessRedirectEdit = <T extends UseFormReturn<FormValues>>({}}readOnly={proUpgradeRequired}type="url"- className=" block w-full rounded-sm border-gray-300 sm:text-sm"+ className="block w-full rounded-sm border-gray-300 sm:text-sm"placeholder={t("external_redirect_url")}defaultValue={eventType.successRedirectUrl || ""}{...formMethods.register("successRedirectUrl")}@@ -422,134 +422,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {formMethods.getValues("locations").concat({ type: newLocationType, ...details }));}- };-- const LocationOptions = () => {- if (!selectedLocation) {- return null;- }-- switch (selectedLocation.value) {- case LocationType.InPerson:- return (- <div>- <label htmlFor="address" className="block text-sm font-medium text-gray-700">- {t("set_address_place")}- </label>- <div className="mt-1">- <input- type="text"- {...locationFormMethods.register("locationAddress")}- id="address"- required- className="block w-full rounded-sm border-gray-300 text-sm"- defaultValue={- formMethods- .getValues("locations")- .find((location) => location.type === LocationType.InPerson)?.address- }- />- </div>- <div className="mt-3">- <Controller- name="displayLocationPublicly"- control={locationFormMethods.control}- render={({ field: { onChange, value } }) => (- <CheckboxField- description={t("display_location_label")}- onChange={(e) => onChange(e.target.checked)}- infomationIconText={t("display_location_info_badge")}></CheckboxField>- )}- />- </div>- </div>- );- case LocationType.Link:- return (- <div>- <label htmlFor="address" className="block text-sm font-medium text-gray-700">- {t("set_link_meeting")}- </label>- <div className="mt-1">- <input- type="text"- {...locationFormMethods.register("locationLink")}- id="address"- required- className=" block w-full rounded-sm border-gray-300 sm:text-sm"- defaultValue={- formMethods.getValues("locations").find((location) => location.type === LocationType.Link)- ?.link- }- />- {locationFormMethods.formState.errors.locationLink && (- <p className="mt-1 text-red-500">- {locationFormMethods.formState.errors.locationLink.message}- </p>- )}- </div>- <div className="mt-3">- <Controller- name="displayLocationPublicly"- control={locationFormMethods.control}- render={({ field: { onChange, value } }) => (- <CheckboxField- description={t("display_location_label")}- onChange={(e) => onChange(e.target.checked)}- infomationIconText={t("display_location_info_badge")}></CheckboxField>- )}- />- </div>- </div>- );- case LocationType.UserPhone:- return (- <div>- <label htmlFor="phonenumber" className="block text-sm font-medium text-gray-700">- {t("set_your_phone_number")}- </label>- <div className="mt-1">- <PhoneInput- control={locationFormMethods.control}- name="locationPhoneNumber"- required- id="locationPhoneNumber"- placeholder={t("host_phone_number")}- rules={{}}- defaultValue={- formMethods- .getValues("locations")- .find((location) => location.type === LocationType.UserPhone)?.hostPhoneNumber- }- />- {locationFormMethods.formState.errors.locationPhoneNumber && (- <p className="mt-1 text-red-500">- {locationFormMethods.formState.errors.locationPhoneNumber.message}- </p>- )}- </div>- </div>- );- case LocationType.Phone:- return <p className="text-sm">{t("cal_invitee_phone_number_scheduling")}</p>;- /* TODO: Render this dynamically from App Store */- case LocationType.GoogleMeet:- return <p className="text-sm">{t("cal_provide_google_meet_location")}</p>;- case LocationType.Zoom:- return <p className="text-sm">{t("cal_provide_zoom_meeting_url")}</p>;- case LocationType.Daily:- return <p className="text-sm">{t("cal_provide_video_meeting_url")}</p>;- case LocationType.Jitsi:- return <p className="text-sm">{t("cal_provide_jitsi_meeting_url")}</p>;- case LocationType.Huddle01:- return <p className="text-sm">{t("cal_provide_huddle01_meeting_url")}</p>;- case LocationType.Tandem:- return <p className="text-sm">{t("cal_provide_tandem_meeting_url")}</p>;- case LocationType.Teams:- return <p className="text-sm">{t("cal_provide_teams_meeting_url")}</p>;- default:- return null;- }+ setShowLocationModal(false);};const removeCustom = (index: number) => {@@ -641,7 +514,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {<Selectoptions={locationOptions}isSearchable={false}- className=" block w-full min-w-0 flex-1 rounded-sm sm:text-sm"+ className="block w-full min-w-0 flex-1 rounded-sm sm:text-sm"onChange={(e) => {if (e?.value) {const newLocationType: LocationType = e.value;@@ -669,7 +542,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {<div className="flex flex-grow items-center"><LocationMarkerIcon className="h-6 w-6" /><span className="w-full border-0 bg-transparent text-sm ltr:ml-2 rtl:mr-2">- {location.link}+ {location.address}</span></div>)}@@ -1089,7 +962,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {id="slug"aria-labelledby="slug-label"required- className=" block w-full min-w-0 flex-1 rounded-none rounded-r-sm border-gray-300 sm:text-sm"+ className="block w-full min-w-0 flex-1 rounded-none rounded-r-sm border-gray-300 sm:text-sm"defaultValue={eventType.slug}{...formMethods.register("slug", {setValueAs: (v) => slugify(v),@@ -1155,7 +1028,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {<div className="w-full"><textareaid="description"- className=" block w-full rounded-sm border-gray-300 text-sm"+ className="block w-full rounded-sm border-gray-300 text-sm "placeholder={t("quick_video_meeting")}{...formMethods.register("description")}defaultValue={asStringOrUndefined(eventType.description)}></textarea>@@ -1312,7 +1185,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {<div className="relative mt-1 rounded-sm"><inputtype="text"- className=" block w-full rounded-sm border-gray-300 text-sm"+ className="block w-full rounded-sm border-gray-300 text-sm "placeholder={t("meeting_with_user")}defaultValue={eventType.eventName || ""}{...formMethods.register("eventName")}@@ -1334,7 +1207,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {{<inputtype="text"- className=" block w-full rounded-sm border-gray-300 text-sm"+ className="block w-full rounded-sm border-gray-300 text-sm "placeholder={t("Example: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f")}defaultValue={(eventType.metadata.smartContractAddress || "") as string}{...formMethods.register("smartContractAddress")}@@ -1515,7 +1388,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {name="hashedLink"data-testid="generated-hash-url"type="text"- className=" grow select-none border-gray-300 bg-gray-50 text-sm text-gray-500 ltr:rounded-l-sm rtl:rounded-r-sm"+ className="grow select-none border-gray-300 bg-gray-50 text-sm text-gray-500 ltr:rounded-l-sm rtl:rounded-r-sm"defaultValue={placeholderHashedLink}/><Tooltip@@ -1651,7 +1524,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {/><selectid=""- className=" block w-full rounded-sm border-gray-300 py-2 pl-3 pr-10 text-base focus:outline-none sm:text-sm"+ className="block w-full rounded-sm border-gray-300 py-2 pl-3 pr-10 text-base focus:outline-none sm:text-sm"{...formMethods.register("periodCountCalendarDays")}defaultValue={eventType.periodCountCalendarDays ? "1" : "0"}><option value="1">{t("calendar_days")}</option>@@ -1725,7 +1598,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {return (<SelectisSearchable={false}- className=" block w-full min-w-0 flex-1 rounded-sm sm:text-sm"+ className="block w-full min-w-0 flex-1 rounded-sm sm:text-sm"onChange={(val) => {if (val) onChange(val.value);}}@@ -1763,7 +1636,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {return (<SelectisSearchable={false}- className=" block w-full min-w-0 flex-1 rounded-sm sm:text-sm"+ className="block w-full min-w-0 flex-1 rounded-sm sm:text-sm"onChange={(val) => {if (val) onChange(val.value);}}@@ -1857,7 +1730,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {</label><inputtype="number"- className="focus:border-primary-500 focus:ring-primary-500 py- block w-20 rounded-sm border-gray-300 shadow-sm [appearance:textfield] ltr:mr-2 rtl:ml-2 sm:text-sm"+ className="focus:border-primary-500 focus:ring-primary-500 py- block w-20 rounded-sm border-gray-300 [appearance:textfield] ltr:mr-2 rtl:ml-2 sm:text-sm"placeholder={`${defaultSeatsInput}`}{...formMethods.register("seatsPerTimeSlot", {valueAsNumber: true,@@ -1951,7 +1824,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {id="requirePayment"name="requirePayment"type="checkbox"- className="text-primary-600 h-4 w-4 rounded border-gray-300"+ className="text-primary-600 h-4 w-4 rounded border-gray-300"defaultChecked={requirePayment}/></div>@@ -1989,7 +1862,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {min="0.5"type="number"required- className=" block w-full rounded-sm border-gray-300 pl-2 pr-12 sm:text-sm"+ className="block w-full rounded-sm border-gray-300 pl-2 pr-12 sm:text-sm"placeholder="Price"onChange={(e) => {field.onChange(e.target.valueAsNumber * 100);@@ -2142,78 +2015,16 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {</div></div></div>- <Dialog open={showLocationModal} onOpenChange={setShowLocationModal}>- <DialogContent asChild>- <div className="inline-block transform rounded-sm bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6 sm:align-middle">- <div className="mb-4 sm:flex sm:items-start">- <div className="bg-secondary-100 mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full sm:mx-0 sm:h-10 sm:w-10">- <LocationMarkerIcon className="text-primary-600 h-6 w-6" />- </div>- <div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">- <h3 className="text-lg font-medium leading-6 text-gray-900" id="modal-title">- {t("edit_location")}- </h3>- <div>- <p className="text-sm text-gray-400">{t("this_input_will_shown_booking_this_event")}</p>- </div>- </div>- </div>- <Form- form={locationFormMethods}- handleSubmit={async (values) => {- const { locationType: newLocation, displayLocationPublicly } = values;- let details = {};- if (newLocation === LocationType.InPerson) {- details = {- address: values.locationAddress,- displayLocationPublicly,- };- }- if (newLocation === LocationType.Link) {- details = { link: values.locationLink, displayLocationPublicly };- }- if (newLocation === LocationType.UserPhone) {- details = { hostPhoneNumber: values.locationPhoneNumber };- }- addLocation(newLocation, details);- setShowLocationModal(false);- }}>- <div>- <Controller- name="locationType"- control={locationFormMethods.control}- render={() => (- <Select- maxMenuHeight={100}- name="location"- defaultValue={selectedLocation}- options={locationOptions}- isSearchable={false}- className=" my-4 block w-full min-w-0 flex-1 rounded-sm border border-gray-300 sm:text-sm"- onChange={(val) => {- if (val) {- locationFormMethods.setValue("locationType", val.value);- locationFormMethods.unregister("locationLink");- locationFormMethods.unregister("locationAddress");- locationFormMethods.unregister("locationPhoneNumber");- setSelectedLocation(val);- }- }}- />- )}- />- </div>- <LocationOptions />- <div className="mt-4 flex justify-end space-x-2">- <Button onClick={() => setShowLocationModal(false)} type="button" color="secondary">- {t("cancel")}- </Button>- <Button type="submit">{t("update")}</Button>- </div>- </Form>- </div>- </DialogContent>- </Dialog>+ <EditLocationDialog+ isOpenDialog={showLocationModal}+ setShowLocationModal={setShowLocationModal}+ saveLocation={addLocation}+ defaultValues={formMethods.getValues("locations")}+ selection={+ selectedLocation ? { value: selectedLocation.value, label: selectedLocation.label } : undefined+ }+ setSelectedLocation={setSelectedLocation}+ /><Controllername="customInputs"control={formMethods.control}diff --git a/apps/web/playwright/booking-pages.test.ts b/apps/web/playwright/booking-pages.test.tsindex f1bc7090c0d..700807a2c1d 100644--- a/apps/web/playwright/booking-pages.test.ts+++ b/apps/web/playwright/booking-pages.test.ts@@ -94,8 +94,8 @@ test.describe("pro user", () => {await pro.login();await page.goto("/bookings/upcoming");- await page.locator('[data-testid="reschedule"]').nth(0).click();- await page.locator('[data-testid="edit"]').click();+ await page.locator('[data-testid="edit_booking"]').nth(0).click();+ await page.locator('[data-testid="reschedule"]').click();await page.waitForNavigation({url: (url) => {const bookingId = url.searchParams.get("rescheduleUid");diff --git a/apps/web/playwright/dynamic-booking-pages.test.ts b/apps/web/playwright/dynamic-booking-pages.test.tsindex b2990654f7d..b57b5cb3b97 100644--- a/apps/web/playwright/dynamic-booking-pages.test.ts+++ b/apps/web/playwright/dynamic-booking-pages.test.ts@@ -35,8 +35,8 @@ test.describe("dynamic booking", () => {// Logged inawait page.goto("/bookings/upcoming");- await page.locator('[data-testid="reschedule"]').nth(0).click();- await page.locator('[data-testid="edit"]').click();+ await page.locator('[data-testid="edit_booking"]').nth(0).click();+ await page.locator('[data-testid="reschedule"]').click();await page.waitForNavigation({url: (url) => {const bookingId = url.searchParams.get("rescheduleUid");diff --git a/apps/web/playwright/reschedule.test.ts b/apps/web/playwright/reschedule.test.tsindex 5bf89893ef6..ec108b2d05a 100644--- a/apps/web/playwright/reschedule.test.ts+++ b/apps/web/playwright/reschedule.test.ts@@ -28,7 +28,7 @@ test.describe("Reschedule Tests", async () => {await user.login();await page.goto("/bookings/upcoming");- await page.locator('[data-testid="reschedule"]').nth(0).click();+ await page.locator('[data-testid="edit_booking"]').nth(0).click();await page.locator('[data-testid="reschedule_request"]').click();diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex ebc9f89142a..eeffac04577 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -435,6 +435,7 @@"in_person_meeting": "In-person meeting","link_meeting": "Link meeting","phone_call": "Phone call",+ "your_number": "Your phone number","phone_number": "Phone Number","attendee_phone_number": "Attendee Phone Number","host_phone_number": "Your Phone Number",@@ -628,7 +629,6 @@"calendar_days": "calendar days","business_days": "business days","set_address_place": "Set an address or place",- "set_your_phone_number": "Set a phone number for the meeting","set_link_meeting": "Set a link to the meeting","cal_invitee_phone_number_scheduling": "Cal will ask your invitee to enter a phone number before scheduling.","cal_provide_google_meet_location": "Cal will provide a Google Meet location.",@@ -646,7 +646,6 @@"into_the_future": "into the future","within_date_range": "Within a date range","indefinitely_into_future": "Indefinitely into the future",- "this_input_will_shown_booking_this_event": "This input will be shown when booking this event","add_new_custom_input_field": "Add new custom input field","quick_chat": "Quick Chat","add_new_team_event_type": "Add a new team event type",@@ -821,6 +820,15 @@"impersonate_user_tip": "All uses of this feature is audited.","impersonating_user_warning": "Impersonating username \"{{user}}\".","impersonating_stop_instructions": "<0>Click Here to stop</0>.",+ "event_location_changed": "Updated - Your event changed the location",+ "location_changed_event_type_subject": "Location Changed: {{eventType}} with {{name}} at {{date}}",+ "current_location": "Current Location",+ "user_phone": "Your phone number",+ "new_location": "New Location",+ "no_location": "No location defined",+ "set_location": "Set Location",+ "update_location": "Update Location",+ "location_updated": "Location updated","email_validation_error": "That doesn't look like an email address","place_where_cal_widget_appear": "Place this code in your HTML where you want your Cal widget to appear.","copy_code": "Copy Code",@@ -835,6 +843,7 @@"install_zapier_app": "Please first install the Zapier App in the app store.","go_to_app_store": "Go to App Store","calendar_error": "Something went wrong, try reconnecting your calendar with all necessary permissions",+ "set_your_phone_number": "Set a phone number for the meeting","calendar_no_busy_slots": "There are no busy slots","display_location_label":"Display on booking page","display_location_info_badge":"Location will be visible before the booking is confirmed",@@ -853,5 +862,9 @@"nevermind": "Nevermind","go_to": "Go to: ","zapier_invite_link": "Zapier Invite Link",- "meeting_url_provided_after_confirmed":"A Meeting URL will be created once the event is confirmed."+ "this_input_will_shown_booking_this_event": "This input will be shown when booking this event",+ "meeting_url_provided_after_confirmed": "A Meeting URL will be created once the event is confirmed.",+ "meeting_url_in_conformation_email": "Meeting url is in the confirmation email",+ "url_start_with_https": "URL needs to start with http:// or https://",+ "number_provided": "Phone number will be provided"}diff --git a/apps/web/server/routers/viewer.tsx b/apps/web/server/routers/viewer.tsxindex daaccbd8c4a..9fbae933ca2 100644--- a/apps/web/server/routers/viewer.tsx+++ b/apps/web/server/routers/viewer.tsx@@ -4,7 +4,7 @@ import _ from "lodash";import { JSONObject } from "superjson/dist/types";import { z } from "zod";-import getApps from "@calcom/app-store/utils";+import getApps, { getLocationOptions } from "@calcom/app-store/utils";import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager";import { checkPremiumUsername } from "@calcom/ee/lib/core/checkPremiumUsername";import { bookingMinimalSelect } from "@calcom/prisma";@@ -13,19 +13,22 @@ import { RecurringEvent } from "@calcom/types/Calendar";import { checkRegularUsername } from "@lib/core/checkRegularUsername";import { sendFeedbackEmail } from "@lib/emails/email-manager";import jackson from "@lib/jackson";+import prisma from "@lib/prisma";import {+ hostedCal,+ isSAMLAdmin,isSAMLLoginEnabled,- samlTenantID,samlProductID,- isSAMLAdmin,- hostedCal,- tenantPrefix,+ samlTenantID,samlTenantProduct,+ tenantPrefix,} from "@lib/saml";import slugify from "@lib/slugify";+import { getTranslation } from "@server/lib/i18n";import { apiKeysRouter } from "@server/routers/viewer/apiKeys";import { availabilityRouter } from "@server/routers/viewer/availability";+import { bookingsRouter } from "@server/routers/viewer/bookings";import { eventTypesRouter } from "@server/routers/viewer/eventTypes";import { TRPCError } from "@trpc/server";@@ -921,11 +924,36 @@ const loggedInViewerRouter = createProtectedRouter()if (process.env.SEND_FEEDBACK_EMAIL && comment) sendFeedbackEmail(feedback);},+ })+ .query("locationOptions", {+ async resolve({ ctx }) {+ const credentials = await prisma.credential.findMany({+ where: {+ userId: ctx.user.id,+ },+ select: {+ id: true,+ type: true,+ key: true,+ userId: true,+ appId: true,+ },+ });++ const integrations = getApps(credentials);++ const t = await getTranslation(ctx.user.locale ?? "en", "common");++ const locationOptions = getLocationOptions(integrations, t);++ return locationOptions;+ },});export const viewerRouter = createRouter().merge(publicViewerRouter).merge(loggedInViewerRouter)+ .merge("bookings.", bookingsRouter).merge("eventTypes.", eventTypesRouter).merge("availability.", availabilityRouter).merge("teams.", viewerTeamsRouter)diff --git a/apps/web/server/routers/viewer/bookings.tsx b/apps/web/server/routers/viewer/bookings.tsxnew file mode 100644index 00000000000..0437e04dfdc--- /dev/null+++ b/apps/web/server/routers/viewer/bookings.tsx@@ -0,0 +1,154 @@+import { SchedulingType } from "@prisma/client";+import dayjs from "dayjs";+import { z } from "zod";++import EventManager from "@calcom/core/EventManager";+import logger from "@calcom/lib/logger";+import { getTranslation } from "@calcom/lib/server/i18n";+import type { AdditionInformation, CalendarEvent } from "@calcom/types/Calendar";++import { sendLocationChangeEmails } from "@lib/emails/email-manager";++import { createProtectedRouter } from "@server/createRouter";+import { TRPCError } from "@trpc/server";++// Common data for all endpoints under webhook+const commonBookingSchema = z.object({+ bookingId: z.number(),+});++export const bookingsRouter = createProtectedRouter()+ .middleware(async ({ ctx, rawInput, next }) => {+ // Endpoints that just read the logged in user's data - like 'list' don't necessary have any input+ if (!rawInput) return next({ ctx: { ...ctx, booking: null } });++ const webhookIdAndEventTypeId = commonBookingSchema.safeParse(rawInput);+ if (!webhookIdAndEventTypeId.success) throw new TRPCError({ code: "PARSE_ERROR" });++ const { bookingId } = webhookIdAndEventTypeId.data;+ const booking = await ctx.prisma.booking.findFirst({+ where: {+ OR: [+ /* If user is organizer */+ { userId: ctx.user.id, id: bookingId },+ /* Or part of a collective booking */+ {+ eventType: {+ schedulingType: SchedulingType.COLLECTIVE,+ users: {+ some: {+ id: ctx.user.id,+ },+ },+ },+ },+ ],+ },+ include: {+ attendees: true,+ eventType: true,+ user: {+ include: { destinationCalendar: true },+ },+ destinationCalendar: true,+ },+ });+ return next({ ctx: { ...ctx, booking } });+ })+ .middleware(async ({ ctx, next }) => {+ // So TS doesn't compain in the previous middleware.+ // This means the user doesn't have access to this booking+ if (!ctx.booking) throw new TRPCError({ code: "UNAUTHORIZED" });+ // Booking here is non-nullable anymore+ return next({ ctx: { ...ctx, booking: ctx.booking } });+ })+ .mutation("editLocation", {+ input: commonBookingSchema.extend({+ newLocation: z.string(),+ }),+ async resolve({ ctx, input }) {+ const { bookingId, newLocation: location } = input;+ const { booking } = ctx;++ try {+ await ctx.prisma.booking.update({+ where: { id: bookingId },+ data: { location },+ });++ const organizer = await ctx.prisma.user.findFirst({+ where: {+ id: booking.userId || 0,+ },+ select: {+ name: true,+ email: true,+ timeZone: true,+ locale: true,+ },+ rejectOnNotFound: true,+ });++ const tOrganizer = await getTranslation(organizer.locale ?? "en", "common");++ const attendeesListPromises = booking.attendees.map(async (attendee) => {+ return {+ name: attendee.name,+ email: attendee.email,+ timeZone: attendee.timeZone,+ language: {+ translate: await getTranslation(attendee.locale ?? "en", "common"),+ locale: attendee.locale ?? "en",+ },+ };+ });++ const attendeesList = await Promise.all(attendeesListPromises);++ const evt: CalendarEvent = {+ title: booking.title || "",+ type: (booking.eventType?.title as string) || booking?.title || "",+ description: booking.description || "",+ startTime: booking.startTime ? dayjs(booking.startTime).format() : "",+ endTime: booking.endTime ? dayjs(booking.endTime).format() : "",+ organizer: {+ email: organizer.email,+ name: organizer.name ?? "Nameless",+ timeZone: organizer.timeZone,+ language: { translate: tOrganizer, locale: organizer.locale ?? "en" },+ },+ attendees: attendeesList,+ uid: booking.uid,+ location,+ destinationCalendar: booking?.destinationCalendar || booking?.user?.destinationCalendar,+ };++ const eventManager = new EventManager(ctx.user);+ const scheduleResult = await eventManager.create(evt);++ const results = scheduleResult.results;+ if (results.length > 0 && results.every((res) => !res.success)) {+ const error = {+ errorCode: "BookingUpdateLocationFailed",+ message: "Updating location failed",+ };+ logger.error(`Booking ${ctx.user.username} failed`, error, results);+ } else {+ const metadata: AdditionInformation = {};+ if (results.length) {+ metadata.hangoutLink = results[0].createdEvent?.hangoutLink;+ metadata.conferenceData = results[0].createdEvent?.conferenceData;+ metadata.entryPoints = results[0].createdEvent?.entryPoints;+ }+ try {+ await sendLocationChangeEmails({ ...evt, additionInformation: metadata });+ } catch (error) {+ console.log("Error sending LocationChangeEmails");+ }+ }+ } catch {+ throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });+ }+ return { message: "Location updated" };+ },+ });diff --git a/packages/app-store/utils.ts b/packages/app-store/utils.tsindex ebfb043a222..81716232575 100644--- a/packages/app-store/utils.ts+++ b/packages/app-store/utils.ts@@ -113,6 +113,14 @@ export function getLocationTypes(): string[] {export function getLocationLabels(t: TFunction) {const defaultLocationLabels = defaultLocations.reduce((locations, location) => {+ if(location.label === "attendee_phone_number") {+ locations[location.value] = t("your_number")+ return locations+ }+ if(location.label === "host_phone_number") {+ locations[location.value] = `${t("phone_call")} (${t("number_provided")})`+ return locations+ }locations[location.value] = t(location.label);return locations;}, {} as Record<LocationType, string>);diff --git a/packages/ui/Button.tsx b/packages/ui/Button.tsxindex b69603125cb..93a0dc864d5 100644--- a/packages/ui/Button.tsx+++ b/packages/ui/Button.tsx@@ -12,6 +12,7 @@ export type ButtonBaseProps = {disabled?: boolean;onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;StartIcon?: SVGComponent;+ startIconClassName?: string;EndIcon?: SVGComponent;shallow?: boolean;};@@ -30,6 +31,7 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPrcolor = "primary",size = "base",StartIcon,+ startIconClassName,EndIcon,shallow,// attributes propagated from `HTMLAnchorProps` or `HTMLButtonProps`@@ -103,7 +105,8 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr<StartIconclassName={classNames("inline",- size === "icon" ? "h-5 w-5 " : "-ml-1 h-5 w-5 ltr:mr-2 rtl:ml-2 rtl:-mr-1"+ size === "icon" ? "h-5 w-5 " : "-ml-1 h-5 w-5 ltr:mr-2 rtl:ml-2 rtl:-mr-1",+ startIconClassName || "")}/>)}diff --git a/packages/ui/Dialog.tsx b/packages/ui/Dialog.tsxindex d2681614573..d056eafd407 100644--- a/packages/ui/Dialog.tsx+++ b/packages/ui/Dialog.tsx@@ -52,7 +52,7 @@ export function Dialog(props: DialogProps) {return (<DialogPrimitive.Root {...dialogProps}>- <DialogPrimitive.Overlay className="fadeIn fixed inset-0 z-40 bg-black bg-opacity-50 transition-opacity" />+ <DialogPrimitive.Overlay className="fixed inset-0 z-40 transition-opacity bg-black bg-opacity-50 fadeIn" />{children}</DialogPrimitive.Root>);@@ -64,7 +64,7 @@ type DialogContentProps = React.ComponentProps<typeof DialogPrimitive["Content"]export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(({ children, ...props }, forwardedRef) => (<DialogPrimitive.Portal>- <DialogPrimitive.Overlay className="fadeIn fixed inset-0 z-40 bg-gray-500 bg-opacity-75 transition-opacity" />+ <DialogPrimitive.Overlay className="fixed inset-0 z-40 transition-opacity bg-gray-500 bg-opacity-75 fadeIn" />{/*zIndex one less than Toast */}<DialogPrimitive.Content{...props}@@ -75,7 +75,7 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps: props.size == "lg"? "p-6 sm:max-w-[70rem]": "p-6 sm:max-w-[35rem]",- "max-h-[560px] overflow-auto overscroll-auto md:h-auto md:max-h-[inherit]",+ "max-h-[560px] overflow-visible overscroll-auto md:h-auto md:max-h-[inherit]",`${props.className || ""}`)}ref={forwardedRef}>@@ -93,7 +93,7 @@ type DialogHeaderProps = {export function DialogHeader(props: DialogHeaderProps) {return (<div className="mb-8">- <h3 className="leading-16 font-cal text-xl text-gray-900" id="modal-title">+ <h3 className="text-xl text-gray-900 leading-16 font-cal" id="modal-title">{props.title}</h3>{props.subtitle && <div className="text-sm text-gray-400">{props.subtitle}</div>}@@ -104,7 +104,7 @@ export function DialogHeader(props: DialogHeaderProps) {export function DialogFooter(props: { children: ReactNode }) {return (<div>- <div className="mt-5 flex justify-end space-x-2 rtl:space-x-reverse">{props.children}</div>+ <div className="flex justify-end mt-5 space-x-2 rtl:space-x-reverse">{props.children}</div></div>);}