- )}
- {!!booking?.eventType?.price && !booking.paid && (
-
- {startTime}:{" "}
-
- {dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}
-
+
+
+
+ {!booking.confirmed && !booking.rejected && (
+ {t("unconfirmed")}
+ )}
+ {!!booking?.eventType?.price && !booking.paid && (
+ Pending payment
+ )}
+
+ {startTime}:{" "}
+
+ {dayjs(booking.startTime).format("HH:mm")} - {dayjs(booking.endTime).format("HH:mm")}
+
+
-
-
- {booking.eventType?.team && {booking.eventType.team.name}: }
- {booking.title}
- {!!booking?.eventType?.price && !booking.paid && (
- Pending payment
- )}
- {!booking.confirmed && !booking.rejected && (
- {t("unconfirmed")}
- )}
-
- {booking.description && (
-
- "{booking.description}"
+
+ {booking.eventType?.team && {booking.eventType.team.name}: }
+ {booking.title}
+ {!!booking?.eventType?.price && !booking.paid && (
+ Pending payment
+ )}
+ {!booking.confirmed && !booking.rejected && (
+ {t("unconfirmed")}
+ )}
- )}
+ {booking.description && (
+
+ "{booking.description}"
+
+ )}
- {booking.attendees.length !== 0 && (
- e.stopPropagation()}>
- {booking.attendees[0].email}
-
- )}
- {isCancelled && booking.rescheduled && (
-
-
-
- )}
+ {booking.attendees.length !== 0 && (
+ e.stopPropagation()}>
+ {booking.attendees[0].email}
+
+ )}
+ {isCancelled && booking.rescheduled && (
+
+
+
+ )}
+
|
diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx
index 4a23427d27..fcea4866b7 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 object
case 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, previousPage
return (
{locationKeyToString(el, t)}{" "}
- {arr.length - 1 !== i && or }
+ {arr.length - 1 !== i && (
+ {t("or_lowercase")}
+ )}
);
})}
@@ -424,7 +428,7 @@ const AvailabilityPage = ({ profile, plan, eventType, workingHours, previousPage
{previousPage === `${WEBAPP_URL}/${profile.slug}` && (
router.back()}
/>
Go Back
diff --git a/apps/web/components/dialog/EditLocationDialog.tsx b/apps/web/components/dialog/EditLocationDialog.tsx
new file mode 100644
index 0000000000..63bfb909e5
--- /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>;
+ 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({
+ mode: "onSubmit",
+ resolver: zodResolver(locationFormSchema),
+ });
+
+ const selectedLocation = useWatch({
+ control: locationFormMethods.control,
+ name: "locationType",
+ });
+
+ const LocationOptions =
+ selectedLocation === LocationType.InPerson ? (
+ <>
+
+
+
+ location.type === LocationType.InPerson
+ )?.address
+ : undefined
+ }
+ />
+
+ {!booking && (
+
+ (
+ 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")}>
+ )}
+ />
+
+ )}
+
+ >
+ ) : selectedLocation === LocationType.Link ? (
+
+
+
+ location.type === LocationType.Link
+ )?.link
+ : undefined
+ }
+ />
+ {locationFormMethods.formState.errors.locationLink && (
+ {t("url_start_with_https")}
+ )}
+
+ {!booking && (
+
+ (
+ location.type === LocationType.Link)
+ ?.displayLocationPublicly
+ : undefined
+ }
+ onChange={(e) => locationFormMethods.setValue("displayLocationPublicly", e.target.checked)}
+ infomationIconText={t("display_location_info_badge")}>
+ )}
+ />
+
+ )}
+
+ ) : selectedLocation === LocationType.UserPhone ? (
+
+
+
+
+ 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 && (
+ Invalid input
+ )}
+
+
+ ) : (
+ {LocationOptionsToString(selectedLocation, t)}
+ );
+
+ return (
+
+ );
+};
diff --git a/apps/web/components/ui/TableActions.tsx b/apps/web/components/ui/TableActions.tsx
index 4750dcd1ce..7f6d316b58 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 = ({ 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.ts
index 550dac307c..163e6d9f8c 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/Calend
import 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-ema
import 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[] = [];
+
+ 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.ts
new file mode 100644
index 0000000000..611ebe269d
--- /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 {
+ 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 `
+
+
+ ${emailHead(headerContent)}
+
+
+ ${emailSchedulingBodyHeader("calendarCircle")}
+ ${emailScheduledBodyHeaderContent(
+ this.attendee.language.translate("event_location_changed"),
+ this.attendee.language.translate("emailed_you_and_any_other_attendees")
+ )}
+ ${emailSchedulingBodyDivider()}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ ${this.getWhat()}
+ ${this.getWhen()}
+ ${this.getWho()}
+ ${this.getLocation()}
+ ${this.getDescription()}
+ ${this.getAdditionalNotes()}
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+ ${emailSchedulingBodyDivider()}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ ${this.getManageLink()}
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+ ${emailBodyLogo()}
+
+
+
+
+ `;
+ }
+}
diff --git a/apps/web/lib/emails/templates/organizer-location-change-email.ts b/apps/web/lib/emails/templates/organizer-location-change-email.ts
new file mode 100644
index 0000000000..15bb3b6b55
--- /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 {
+ 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 `
+
+
+ ${emailHead(headerContent)}
+
+
+ ${emailSchedulingBodyHeader("calendarCircle")}
+ ${emailScheduledBodyHeaderContent(
+ this.calEvent.organizer.language.translate("event_location_changed"),
+ this.calEvent.organizer.language.translate("emailed_you_and_any_other_attendees")
+ )}
+ ${emailSchedulingBodyDivider()}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ ${this.getWhat()}
+ ${this.getWhen()}
+ ${this.getWho()}
+ ${this.getLocation()}
+ ${this.getDescription()}
+ ${this.getAdditionalNotes()}
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+ ${emailSchedulingBodyDivider()}
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ ${this.getManageLink()}
+
+ |
+
+
+
+
+
+ |
+
+
+
+
+ ${emailBodyLogo()}
+
+
+
+
+ `;
+ }
+}
diff --git a/apps/web/lib/linkValueToString.ts b/apps/web/lib/linkValueToString.ts
new file mode 100644
index 0000000000..777296a451
--- /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.tsx
index c0d3b9d0d6..c9d96287fb 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].tsx
index a3c58c4bf7..0bb44a9b5d 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 = >({
}}
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) => {
formMethods.getValues("locations").concat({ type: newLocationType, ...details })
);
}
- };
-
- const LocationOptions = () => {
- if (!selectedLocation) {
- return null;
- }
-
- switch (selectedLocation.value) {
- case LocationType.InPerson:
- return (
-
-
-
- location.type === LocationType.InPerson)?.address
- }
- />
-
-
- (
- onChange(e.target.checked)}
- infomationIconText={t("display_location_info_badge")}>
- )}
- />
-
-
- );
- case LocationType.Link:
- return (
-
-
-
- location.type === LocationType.Link)
- ?.link
- }
- />
- {locationFormMethods.formState.errors.locationLink && (
-
- {locationFormMethods.formState.errors.locationLink.message}
-
- )}
-
-
- (
- onChange(e.target.checked)}
- infomationIconText={t("display_location_info_badge")}>
- )}
- />
-
-
- );
- case LocationType.UserPhone:
- return (
-
-
-
- location.type === LocationType.UserPhone)?.hostPhoneNumber
- }
- />
- {locationFormMethods.formState.errors.locationPhoneNumber && (
-
- {locationFormMethods.formState.errors.locationPhoneNumber.message}
-
- )}
-
-
- );
- case LocationType.Phone:
- return {t("cal_invitee_phone_number_scheduling")} ;
- /* TODO: Render this dynamically from App Store */
- case LocationType.GoogleMeet:
- return {t("cal_provide_google_meet_location")} ;
- case LocationType.Zoom:
- return {t("cal_provide_zoom_meeting_url")} ;
- case LocationType.Daily:
- return {t("cal_provide_video_meeting_url")} ;
- case LocationType.Jitsi:
- return {t("cal_provide_jitsi_meeting_url")} ;
- case LocationType.Huddle01:
- return {t("cal_provide_huddle01_meeting_url")} ;
- case LocationType.Tandem:
- return {t("cal_provide_tandem_meeting_url")} ;
- case LocationType.Teams:
- return {t("cal_provide_teams_meeting_url")} ;
- default:
- return null;
- }
+ setShowLocationModal(false);
};
const removeCustom = (index: number) => {
@@ -641,7 +514,7 @@ const EventTypePage = (props: inferSSRProps) => {
-
+
{
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.ts
index b2990654f7..b57b5cb3b9 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 in
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/reschedule.test.ts b/apps/web/playwright/reschedule.test.ts
index 5bf89893ef..ec108b2d05 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.json
index ebc9f89142..eeffac0457 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 stop0>.",
+ "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.tsx
index daaccbd8c4..9fbae933ca 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 {
- isSAMLLoginEnabled,
- samlTenantID,
- samlProductID,
- isSAMLAdmin,
hostedCal,
- tenantPrefix,
+ isSAMLAdmin,
+ isSAMLLoginEnabled,
+ samlProductID,
+ 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.tsx
new file mode 100644
index 0000000000..0437e04dfd
--- /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.ts
index ebfb043a22..8171623257 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);
diff --git a/packages/ui/Button.tsx b/packages/ui/Button.tsx
index b69603125c..93a0dc864d 100644
--- a/packages/ui/Button.tsx
+++ b/packages/ui/Button.tsx
@@ -12,6 +12,7 @@ export type ButtonBaseProps = {
disabled?: boolean;
onClick?: (event: React.MouseEvent) => void;
StartIcon?: SVGComponent;
+ startIconClassName?: string;
EndIcon?: SVGComponent;
shallow?: boolean;
};
@@ -30,6 +31,7 @@ export const Button = forwardRef
)}
diff --git a/packages/ui/Dialog.tsx b/packages/ui/Dialog.tsx
index d268161457..d056eafd40 100644
--- a/packages/ui/Dialog.tsx
+++ b/packages/ui/Dialog.tsx
@@ -52,7 +52,7 @@ export function Dialog(props: DialogProps) {
return (
-
+
{children}
);
@@ -64,7 +64,7 @@ type DialogContentProps = React.ComponentProps(
({ children, ...props }, forwardedRef) => (
-
+
{/*zIndex one less than Toast */}
@@ -93,7 +93,7 @@ type DialogHeaderProps = {
export function DialogHeader(props: DialogHeaderProps) {
return (
-
+
{props.title}
{props.subtitle && {props.subtitle} }
@@ -104,7 +104,7 @@ export function DialogHeader(props: DialogHeaderProps) {
export function DialogFooter(props: { children: ReactNode }) {
return (
- {props.children}
+ {props.children}
);
}
|