feat: added Rating Template to Workflows (#14215)

Co-authored-by: alishaz-polymath <alishahbaz7@gmail.com>
Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
This commit is contained in:
Peer Richelsen
2024-04-04 09:58:52 -07:00
committed by GitHub
co-authored by alishaz-polymath Syed Ali Shahbaz
parent 844076badb
commit 9bd3a362a2
22 changed files with 845 additions and 408 deletions
@@ -27,6 +27,7 @@ import {
} from "../lib/reminders/providers/sendgridProvider";
import type { VariablesType } from "../lib/reminders/templates/customTemplate";
import customTemplate from "../lib/reminders/templates/customTemplate";
import emailRatingTemplate from "../lib/reminders/templates/emailRatingTemplate";
import emailReminderTemplate from "../lib/reminders/templates/emailReminderTemplate";
async function handler(req: NextApiRequest, res: NextApiResponse) {
@@ -188,6 +189,8 @@ 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}`,
ratingUrl: `${bookerUrl}/booking/${reminder.booking.uid}?rating`,
noShowUrl: `${bookerUrl}/booking/${reminder.booking.uid}?noShow=true`,
};
const emailLocale = locale || "en";
const emailSubject = customTemplate(
@@ -226,6 +229,30 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
name || "",
!!reminder.booking.user?.hideBranding
);
} else if (reminder.workflowStep.template === WorkflowTemplates.RATING) {
const organizerOrganizationProfile = await prisma.profile.findFirst({
where: {
userId: reminder.booking.user?.id,
},
});
const organizerOrganizationId = organizerOrganizationProfile?.organizationId;
const bookerUrl = await getBookerBaseUrl(
reminder.booking.eventType?.team?.parentId ?? organizerOrganizationId ?? null
);
emailContent = emailRatingTemplate({
isEditingMode: true,
action: reminder.workflowStep.action || WorkflowActions.EMAIL_ADDRESS,
timeFormat: getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
startTime: reminder.booking.startTime.toISOString() || "",
endTime: reminder.booking.endTime.toISOString() || "",
eventName: reminder.booking.eventType?.title || "",
timeZone: timeZone || "",
organizer: reminder.booking.user?.name || "",
name: name || "",
ratingUrl: `${bookerUrl}/booking/${reminder.booking.uid}?rating` || "",
noShowUrl: `${bookerUrl}/booking/${reminder.booking.uid}?noShow=true` || "",
});
}
if (emailContent.emailSubject.length > 0 && !emailBodyEmpty && sendTo) {