Added basic pages for template editing BOD-85
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import React from "react";
|
||||
import { Button, notification } from "antd";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UPDATE_TEMPLATE } from "../../graphql/templates.queries";
|
||||
|
||||
export default function ShopTemplateSaveButton({ templateId, html, gql }) {
|
||||
const { t } = useTranslation();
|
||||
const [updateTemplate] = useMutation(UPDATE_TEMPLATE);
|
||||
|
||||
const handleSave = async () => {
|
||||
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),
|
||||
}),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button disabled={!!!templateId} onClick={handleSave}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user