Modified how template list is generated to be a function to allow checking whether the templates can be printed.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Button, notification } from "antd";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -12,15 +12,15 @@ export default function ShopTemplateSaveButton({
|
||||
emailEditorRef,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updateTemplate] = useMutation(UPDATE_TEMPLATE);
|
||||
|
||||
const handleSave = async () => {
|
||||
logImEXEvent("shop_template_update");
|
||||
|
||||
setLoading(true);
|
||||
emailEditorRef.current.exportHtml(async (data) => {
|
||||
inlineCss(data.html, {
|
||||
url: `${window.location.protocol}://${window.location.host}/`,
|
||||
preserveMediaQueries: true,
|
||||
}).then(async function (inlineHtml) {
|
||||
const result = await updateTemplate({
|
||||
variables: {
|
||||
@@ -43,12 +43,13 @@ export default function ShopTemplateSaveButton({
|
||||
}),
|
||||
});
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Button disabled={!!!templateId} onClick={handleSave}>
|
||||
<Button disabled={!!!templateId} loading={loading} onClick={handleSave}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user