fix: add new styling for emoji links (#14481)
This commit is contained in:
1 parent
4aeb6b7c9b
commit
8bb5200dd8
6 files changed
+57
-25
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import client from "@sendgrid/client";
|
||||
import type { MailData } from "@sendgrid/helpers/classes/mail";
|
||||
import sgMail from "@sendgrid/mail";
|
||||
import { JSDOM } from "jsdom";
|
||||
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import { setTestEmail } from "@calcom/lib/testEmails";
|
||||
@@ -70,7 +71,7 @@ export function sendSendgridMail(
|
||||
name: addData.sender || SENDER_NAME,
|
||||
},
|
||||
subject: mailData.subject,
|
||||
html: mailData.html || "",
|
||||
html: addHTMLStyles(mailData.html),
|
||||
batchId: mailData.batchId,
|
||||
replyTo: mailData.replyTo || senderEmail,
|
||||
attachments: mailData.attachments,
|
||||
@@ -109,3 +110,22 @@ export function deleteScheduledSend(referenceId: string | null) {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
|
||||
function addHTMLStyles(html?: string) {
|
||||
if (!html) {
|
||||
return "";
|
||||
}
|
||||
const dom = new JSDOM(html);
|
||||
const document = dom.window.document;
|
||||
|
||||
// Select all <a> tags inside <h6> elements --> only used for emojis in rating template
|
||||
const links = document.querySelectorAll("h6 a");
|
||||
|
||||
links.forEach((link) => {
|
||||
const htmlLink = link as HTMLElement;
|
||||
htmlLink.style.fontSize = "20px";
|
||||
htmlLink.style.textDecoration = "none";
|
||||
});
|
||||
|
||||
return dom.serialize();
|
||||
}
|
||||
@@ -50,28 +50,28 @@ const emailRatingTemplate = ({
|
||||
endTime = dayjs(endTime).tz(timeZone).format(currentTimeFormat);
|
||||
}
|
||||
|
||||
const emailSubject = `How was your recent experience?: ${eventName}`;
|
||||
const emailSubject = `How was your recent experience? ${eventName}`;
|
||||
|
||||
const introHtml = `<body>Hi${
|
||||
const introHtml = `<p>Hi${
|
||||
name ? ` ${name}` : ""
|
||||
},<br><br>We're always looking to improve our customer's experience. How satisfied were you with your recent meeting?<br><br>`;
|
||||
},<br><br>We're always looking to improve our customer's experience. How satisfied were you with your recent meeting?<br></p>`;
|
||||
|
||||
const ratingHtml = `<a href="${ratingUrl}=1">😠</a> <a href="${ratingUrl}=2">🙁</a> <a href="${ratingUrl}=3">😐</a> <a href="${ratingUrl}=4">😄</a> <a href="${ratingUrl}=5">😍</a><br><br>`;
|
||||
const ratingHtml = `<h6><a href="${ratingUrl}=1">😠 </a> <a href="${ratingUrl}=2">🙁 </a> <a href="${ratingUrl}=3">😐 </a> <a href="${ratingUrl}=4">😄 </a> <a href="${ratingUrl}=5">😍</a></h6>`;
|
||||
|
||||
const noShowHtml = `<div><a href="${noShowUrl}">${organizer} didn't join the meeting</a></div><br><br>`;
|
||||
const noShowHtml = `${organizer} didn't join the meeting?<a href="${noShowUrl}"> Reschedule here</a><br><br>`;
|
||||
|
||||
const eventHtml = `<div><strong class="editor-text-bold">Event: </strong></div>${eventName}<br><br>`;
|
||||
const eventHtml = `<strong>Event: </strong>${eventName}<br><br>`;
|
||||
|
||||
const dateTimeHtml = `<div><strong class="editor-text-bold">Date & Time: </strong></div>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
const dateTimeHtml = `<strong>Date & Time: </strong>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
||||
|
||||
const attendeeHtml = `<div><strong class="editor-text-bold">Attendees: </strong></div>You & ${organizer}<br><br>`;
|
||||
const attendeeHtml = `<strong>Attendees: </strong>You & ${organizer}<br><br>`;
|
||||
|
||||
const branding = !isBrandingDisabled && !isEditingMode ? `<br><br>_<br><br>Scheduling by ${APP_NAME}` : "";
|
||||
const branding =
|
||||
!isBrandingDisabled && !isEditingMode ? `<div>_<br><br>Scheduling by ${APP_NAME}</div>` : "";
|
||||
|
||||
const endingHtml = `This survey was triggered by a Workflow in Cal.${branding}</body>`;
|
||||
const endingHtml = `This survey was triggered by a Workflow in Cal.${branding}`;
|
||||
|
||||
const emailBody =
|
||||
introHtml + ratingHtml + noShowHtml + eventHtml + dateTimeHtml + attendeeHtml + endingHtml;
|
||||
const emailBody = `<body>${introHtml}${ratingHtml}<p>${noShowHtml}${eventHtml}${dateTimeHtml}${attendeeHtml}${endingHtml}</p></body>`;
|
||||
|
||||
return { emailSubject, emailBody };
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user