feat: add workflow vars and search for event types (#17343)

* Udit:goat - thank you for this

* improve searchbar

* remove unused code

* add workflow vars

* change requested

* requested changes

* changes

* type-fix??

* type-fix??

* ----
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2024-10-25 22:38:48 +00:00
1 parent b9128a7a0b
commit 097c14ca64
12 files changed
+108 -17

No files matched your search

@@ -205,6 +205,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
rescheduleLink: `${bookerUrl}/reschedule/${reminder.booking.uid}`,
ratingUrl: `${bookerUrl}/booking/${reminder.booking.uid}?rating`,
noShowUrl: `${bookerUrl}/booking/${reminder.booking.uid}?noShow=true`,
attendeeTimezone: reminder.booking.attendees[0].timeZone,
eventTimeInAttendeeTimezone: dayjs(reminder.booking.startTime).tz(
reminder.booking.attendees[0].timeZone
),
eventEndTimeInAttendeeTimezone: dayjs(reminder.booking?.endTime).tz(
reminder.booking.attendees[0].timeZone
),
};
const emailLocale = locale || "en";
const emailSubject = customTemplate(
@@ -134,6 +134,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
meetingUrl: bookingMetadataSchema.parse(reminder.booking?.metadata || {})?.videoCallUrl,
cancelLink: `${bookerUrl}/booking/${reminder.booking.uid}?cancel=true`,
rescheduleLink: `${bookerUrl}/reschedule/${reminder.booking.uid}`,
attendeeTimezone: reminder.booking.attendees[0].timeZone,
eventTimeInAttendeeTimezone: dayjs(reminder.booking.startTime).tz(
reminder.booking.attendees[0].timeZone
),
eventEndTimeInAttendeeTimezone: dayjs(reminder.booking?.endTime).tz(
reminder.booking.attendees[0].timeZone
),
};
const customMessage = customTemplate(
reminder.workflowStep.reminderBody || "",
@@ -64,6 +64,15 @@ export const DYNAMIC_TEXT_VARIABLES = [
"reschedule_url",
"rating_url",
"no_show_url",
"attendee_timezone",
"event_start_time_in_attendee_timezone",
"event_end_time_in_attendee_timezone",
];
export const FORMATTED_DYNAMIC_TEXT_VARIABLES = ["event_date_", "event_time_", "event_end_time_"];
export const FORMATTED_DYNAMIC_TEXT_VARIABLES = [
"event_date_",
"event_time_",
"event_end_time_",
"event_start_time_in_attendee_timezone_",
"event_end_time_in_attendee_timezone_",
];
@@ -163,6 +163,9 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
rescheduleLink: `${bookerUrl}/reschedule/${evt.uid}`,
ratingUrl: `${bookerUrl}/booking/${evt.uid}?rating`,
noShowUrl: `${bookerUrl}/booking/${evt.uid}?noShow=true`,
attendeeTimezone: evt.attendees[0].timeZone,
eventTimeInAttendeeTimezone: dayjs(startTime).tz(evt.attendees[0].timeZone),
eventEndTimeInAttendeeTimezone: dayjs(endTime).tz(evt.attendees[0].timeZone),
};
const locale =
@@ -160,6 +160,9 @@ export const scheduleSMSReminder = async (args: ScheduleTextReminderArgs) => {
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
cancelLink: `${evt.bookerUrl ?? WEBSITE_URL}/booking/${evt.uid}?cancel=true`,
rescheduleLink: `${evt.bookerUrl ?? WEBSITE_URL}/reschedule/${evt.uid}`,
attendeeTimezone: evt.attendees[0].timeZone,
eventTimeInAttendeeTimezone: dayjs(evt.startTime).tz(evt.attendees[0].timeZone),
eventEndTimeInAttendeeTimezone: dayjs(evt.endTime).tz(evt.attendees[0].timeZone),
};
const customMessage = customTemplate(smsMessage, variables, locale, evt.organizer.timeFormat);
smsMessage = customMessage.text;
@@ -23,6 +23,9 @@ export type VariablesType = {
rescheduleLink?: string;
ratingUrl?: string;
noShowUrl?: string;
attendeeTimezone?: string;
eventTimeInAttendeeTimezone?: Dayjs;
eventEndTimeInAttendeeTimezone?: Dayjs;
};
const customTemplate = (
@@ -83,7 +86,16 @@ const customTemplate = (
.replaceAll("{RESCHEDULE_URL}", rescheduleLink)
.replaceAll("{MEETING_URL}", variables.meetingUrl || "")
.replaceAll("{RATING_URL}", variables.ratingUrl || "")
.replaceAll("{NO_SHOW_URL}", variables.noShowUrl || "");
.replaceAll("{NO_SHOW_URL}", variables.noShowUrl || "")
.replaceAll("{ATTENDEE_TIMEZONE}", variables.attendeeTimezone || "")
.replaceAll(
"{EVENT_START_TIME_IN_ATTENDEE_TIMEZONE}",
variables.eventTimeInAttendeeTimezone?.format(currentTimeFormat) || ""
)
.replaceAll(
"{EVENT_END_TIME_IN_ATTENDEE_TIMEZONE}",
variables.eventEndTimeInAttendeeTimezone?.format(currentTimeFormat) || ""
);
const customInputvariables = dynamicText.match(/\{(.+?)}/g)?.map((variable) => {
return variable.replace("{", "").replace("}", "");
@@ -5,6 +5,7 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
import { useDebounce } from "@calcom/lib/hooks/useDebounce";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { useTypedQuery } from "@calcom/lib/hooks/useTypedQuery";
import { HttpError } from "@calcom/lib/http-error";
@@ -46,6 +47,8 @@ const DuplicateDialog = () => {
const {
data: { pageSlug, slug, ...defaultValues },
} = useTypedQuery(querySchema);
const [searchTerm, setSearchTerm] = useState("");
const debouncedSearchTerm = useDebounce(searchTerm, 500);
// react hook form
const form = useForm({
@@ -77,6 +80,7 @@ const DuplicateDialog = () => {
await utils.viewer.eventTypes.getUserEventGroups.invalidate();
await utils.viewer.eventTypes.getEventTypesFromGroup.invalidate({
limit: 10,
searchQuery: debouncedSearchTerm,
group: { teamId: eventType?.teamId, parentId: eventType?.parentId },
});