Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cancel and reschedule reason variables in workflows #18305

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,12 @@
"event_end_time_info": "The event end time",
"cancel_url_variable": "Cancel URL",
"cancel_url_info": "The URL to cancel the booking",
"cancel_reason_variable": "Cancellation Reason",
"cancel_reason_info": "The reason for canceling the booking",
"reschedule_url_variable": "Reschedule URL",
"reschedule_url_info": "The URL to reschedule the booking",
"reschedule_reason_variable": "Reschedule Reason",
"reschedule_reason_info": "The reason for rescheduling the booking",
"invalid_event_name_variables": "{{item}} is an invalid variable in your event name",
"select_all": "Select All",
"default_conferencing_bulk_title": "Bulk update existing event types",
Expand Down
4 changes: 4 additions & 0 deletions packages/features/bookings/lib/handleConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export async function handleConfirmation(args: {
endTime: Date;
uid: string;
smsReminderNumber: string | null;
cancellationReason?: string | null;
metadata: Prisma.JsonValue | null;
customInputs: Prisma.JsonValue;
eventType: {
Expand Down Expand Up @@ -230,6 +231,7 @@ export async function handleConfirmation(args: {
},
},
description: true,
cancellationReason: true,
attendees: true,
location: true,
uid: true,
Expand Down Expand Up @@ -292,6 +294,7 @@ export async function handleConfirmation(args: {
uid: true,
startTime: true,
metadata: true,
cancellationReason: true,
endTime: true,
smsReminderNumber: true,
description: true,
Expand Down Expand Up @@ -325,6 +328,7 @@ export async function handleConfirmation(args: {
const eventTypeSlug = updatedBookings[index].eventType?.slug || "";
const evtOfBooking = {
...evt,
rescheduleReason: updatedBookings[index].cancellationReason || null,
anikdhabal marked this conversation as resolved.
Show resolved Hide resolved
metadata: { videoCallUrl: meetingUrl },
eventType: {
slug: eventTypeSlug,
Expand Down
1 change: 1 addition & 0 deletions packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,7 @@ async function handler(

const evtWithMetadata = {
...evt,
rescheduleReason,
metadata,
eventType: { slug: eventType.slug, schedulingType: eventType.schedulingType, hosts: eventType.hosts },
bookerUrl,
Expand Down
2 changes: 2 additions & 0 deletions packages/features/bookings/lib/handleSeats/handleSeats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const handleSeats = async (newSeatedBookingObject: NewSeatedBookingObject) => {
evt,
workflows,
rescheduledBy,
rescheduleReason,
} = newSeatedBookingObject;

const loggerWithEventDetails = createLoggerWithEventDetails(eventType.id, reqBodyUser, eventType.slug);
Expand Down Expand Up @@ -110,6 +111,7 @@ const handleSeats = async (newSeatedBookingObject: NewSeatedBookingObject) => {
smsReminderNumber: smsReminderNumber || null,
calendarEvent: {
...evt,
rescheduleReason,
...{
metadata,
eventType: {
Expand Down
2 changes: 2 additions & 0 deletions packages/features/ee/workflows/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const DYNAMIC_TEXT_VARIABLES = [
"additional_notes",
"meeting_url",
"cancel_url",
"cancel_reason",
"reschedule_url",
"reschedule_reason",
"rating_url",
"no_show_url",
"attendee_timezone",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) =>
responses: evt.responses,
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
cancelLink: `${bookerUrl}/booking/${evt.uid}?cancel=true`,
cancelReason: evt.cancellationReason,
rescheduleLink: `${bookerUrl}/reschedule/${evt.uid}`,
rescheduleReason: evt.rescheduleReason,
ratingUrl: `${bookerUrl}/booking/${evt.uid}?rating`,
noShowUrl: `${bookerUrl}/booking/${evt.uid}?noShow=true`,
attendeeTimezone: evt.attendees[0].timeZone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type ExtendedCalendarEvent = Omit<CalendarEvent, "bookerUrl"> & {
schedulingType?: SchedulingType | null;
hosts?: { user: { email: string; destinationCalendar?: { primaryEmail: string | null } | null } }[];
};
rescheduleReason?: string | null;
cancellationReason?: string | null;
bookerUrl: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export type BookingInfo = {
additionalNotes?: string | null;
responses?: CalEventResponses | null;
metadata?: Prisma.JsonValue;
cancellationReason?: string | null;
rescheduleReason?: string | null;
};

export type ScheduleTextReminderAction = Extract<
Expand Down Expand Up @@ -159,7 +161,9 @@ export const scheduleSMSReminder = async (args: ScheduleTextReminderArgs) => {
responses: evt.responses,
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
cancelLink: `${evt.bookerUrl ?? WEBSITE_URL}/booking/${evt.uid}?cancel=true`,
cancelReason: evt.cancellationReason,
rescheduleLink: `${evt.bookerUrl ?? WEBSITE_URL}/reschedule/${evt.uid}`,
rescheduleReason: evt.rescheduleReason,
attendeeTimezone: evt.attendees[0].timeZone,
eventTimeInAttendeeTimezone: dayjs(evt.startTime).tz(evt.attendees[0].timeZone),
eventEndTimeInAttendeeTimezone: dayjs(evt.endTime).tz(evt.attendees[0].timeZone),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export type VariablesType = {
responses?: CalEventResponses | null;
meetingUrl?: string;
cancelLink?: string;
cancelReason?: string | null;
rescheduleLink?: string;
rescheduleReason?: string | null;
ratingUrl?: string;
noShowUrl?: string;
attendeeTimezone?: string;
Expand Down Expand Up @@ -83,7 +85,9 @@ const customTemplate = (
.replaceAll("{ATTENDEE_EMAIL}", variables.attendeeEmail || "")
.replaceAll("{TIMEZONE}", variables.timeZone || "")
.replaceAll("{CANCEL_URL}", cancelLink)
.replaceAll("{CANCELLATION_REASON}", variables.cancelReason || "")
.replaceAll("{RESCHEDULE_URL}", rescheduleLink)
.replaceAll("{RESCHEDULE_REASON}", variables.rescheduleReason || "")
.replaceAll("{MEETING_URL}", variables.meetingUrl || "")
.replaceAll("{RATING_URL}", variables.ratingUrl || "")
.replaceAll("{NO_SHOW_URL}", variables.noShowUrl || "")
Expand Down
Loading