Added new HTML editor with some breaking changes.
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user