Files
bodyshop/client/src/components/print-wrapper/print-wrapper.component.jsx
2021-06-07 12:27:14 -07:00

28 lines
731 B
JavaScript

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