Print IH invoices after creation IO-724

This commit is contained in:
Patrick Fic
2021-02-26 16:02:59 -08:00
parent 5945e27148
commit 510bf9c1b9
5 changed files with 53 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import { MailFilled, PrinterFilled } from "@ant-design/icons";
import { Space } from "antd";
import React from "react";
import { Space, Spin } from "antd";
import React, { useState } from "react";
import { GenerateDocument } from "../../utils/RenderTemplate";
export default function PrintWrapperComponent({
@@ -8,15 +8,19 @@ export default function PrintWrapperComponent({
messageObject = {},
children,
}) {
const [loading, setLoading] = useState(false);
const handlePrint = async (type) => {
setLoading(true);
await GenerateDocument(templateObject, messageObject, type);
setLoading(false);
};
return (
<Space>
{children || null}
<PrinterFilled
onClick={() => GenerateDocument(templateObject, {}, "p")}
/>
<MailFilled
onClick={() => GenerateDocument(templateObject, messageObject, "e")}
/>
<PrinterFilled onClick={() => handlePrint("p")} />
<MailFilled onClick={() => handlePrint("e")} />
{loading && <Spin size="small" />}
</Space>
);
}