Added new HTML editor with some breaking changes.

This commit is contained in:
Patrick Fic
2020-08-14 15:50:36 -07:00
parent 57cbc6961c
commit 873e81556d
20 changed files with 574 additions and 358 deletions

View File

@@ -5,28 +5,41 @@ import { useTranslation } from "react-i18next";
import { UPDATE_TEMPLATE } from "../../graphql/templates.queries";
import { logImEXEvent } from "../../firebase/firebase.utils";
export default function ShopTemplateSaveButton({ templateId, html, gql }) {
export default function ShopTemplateSaveButton({
templateId,
gql,
emailEditorRef,
}) {
const { t } = useTranslation();
const [updateTemplate] = useMutation(UPDATE_TEMPLATE);
const handleSave = async () => {
logImEXEvent("shop_template_update");
const result = await updateTemplate({
variables: {
templateId: templateId,
template: { query: gql, html },
},
});
if (!!!result.errors) {
notification["success"]({ message: t("templates.successes.updated") });
} else {
notification["error"]({
message: t("templates.errors.updating", {
error: JSON.stringify(result.errors),
}),
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,
},
},
});
}
if (!!!result.errors) {
notification["success"]({
message: t("templates.successes.updated"),
});
} else {
notification["error"]({
message: t("templates.errors.updating", {
error: JSON.stringify(result.errors),
}),
});
}
});
};
return (