Minor fixes throughout the system.

This commit is contained in:
Patrick Fic
2020-08-17 13:47:10 -07:00
parent 5efb21ada7
commit 9b9feffdfa
20 changed files with 2292 additions and 141 deletions

View File

@@ -4,6 +4,7 @@ import { useMutation } from "@apollo/react-hooks";
import { useTranslation } from "react-i18next";
import { UPDATE_TEMPLATE } from "../../graphql/templates.queries";
import { logImEXEvent } from "../../firebase/firebase.utils";
import inlineCss from "inline-css";
export default function ShopTemplateSaveButton({
templateId,
@@ -17,28 +18,32 @@ export default function ShopTemplateSaveButton({
logImEXEvent("shop_template_update");
emailEditorRef.current.exportHtml(async (data) => {
console.log("handleSave -> html", data);
const result = await updateTemplate({
variables: {
templateId: templateId,
template: {
query: gql,
html: data.html,
jsontemplate: data.design,
console.log(data.html);
inlineCss(data.html, {
url: `${window.location.protocol}://${window.location.host}`,
}).then(async function (inlineHtml) {
const result = await updateTemplate({
variables: {
templateId: templateId,
template: {
query: gql,
html: inlineHtml,
jsontemplate: data.design,
},
},
},
});
if (!!!result.errors) {
notification["success"]({
message: t("templates.successes.updated"),
});
} else {
notification["error"]({
message: t("templates.errors.updating", {
error: JSON.stringify(result.errors),
}),
});
}
});
if (!!!result.errors) {
notification["success"]({
message: t("templates.successes.updated"),
});
} else {
notification["error"]({
message: t("templates.errors.updating", {
error: JSON.stringify(result.errors),
}),
});
}
});
};