Skip to content

Commit

Permalink
fix: email embed styles (#2554)
Browse files Browse the repository at this point in the history
Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
  • Loading branch information
pandeymangg and mattinannt committed May 2, 2024
1 parent 0e102ea commit fc15017
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getPreviewEmailTemplateHtml } from "@formbricks/email/components/survey/PreviewEmailTemplste";
import { getPreviewEmailTemplateHtml } from "@formbricks/email/components/survey/PreviewEmailTemplate";
import { WEBAPP_URL } from "@formbricks/lib/constants";
import { getProductByEnvironmentId } from "@formbricks/lib/product/service";
import { COLOR_DEFAULTS } from "@formbricks/lib/styling/constants";
import { getSurvey } from "@formbricks/lib/survey/service";
import { getStyling } from "@formbricks/lib/utils/styling";

export const getEmailTemplateHtml = async (surveyId) => {
export const getEmailTemplateHtml = async (surveyId: string) => {
const survey = await getSurvey(surveyId);
if (!survey) {
throw new Error("Survey not found");
Expand All @@ -13,9 +13,10 @@ export const getEmailTemplateHtml = async (surveyId) => {
if (!product) {
throw new Error("Product not found");
}
const brandColor = product.styling.brandColor?.light || COLOR_DEFAULTS.brandColor;

const styling = getStyling(product, survey);
const surveyUrl = WEBAPP_URL + "/s/" + survey.id;
const html = getPreviewEmailTemplateHtml(survey, surveyUrl, brandColor);
const html = getPreviewEmailTemplateHtml(survey, surveyUrl, styling);
const doctype =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
const htmlCleaned = html.toString().replace(doctype, "");
Expand Down
Loading

0 comments on commit fc15017

Please sign in to comment.