Modified how template list is generated to be a function to allow checking whether the templates can be printed.

This commit is contained in:
Patrick Fic
2020-09-11 14:43:04 -07:00
parent 984c001bd8
commit f7e74c5043
20 changed files with 167 additions and 207 deletions

View File

@@ -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>
);