43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { Button, Space } from "antd";
|
|
import React, { useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
|
import { TemplateList } from "../../utils/TemplateConstants";
|
|
import { useNotification } from "../../contexts/Notifications/notificationContext.jsx";
|
|
|
|
export default function BillPrintButton({ billid }) {
|
|
const { t } = useTranslation();
|
|
const [loading, setLoading] = useState(false);
|
|
const Templates = TemplateList("job_special");
|
|
const notification = useNotification();
|
|
|
|
const submitHandler = async () => {
|
|
setLoading(true);
|
|
try {
|
|
await GenerateDocument(
|
|
{
|
|
name: Templates.parts_invoice_label_single.key,
|
|
variables: {
|
|
id: billid
|
|
}
|
|
},
|
|
{},
|
|
"p",
|
|
null,
|
|
notification
|
|
);
|
|
} catch (e) {
|
|
console.warn("Warning: Error generating a document.");
|
|
}
|
|
setLoading(false);
|
|
};
|
|
|
|
return (
|
|
<Space wrap>
|
|
<Button loading={loading} onClick={submitHandler}>
|
|
{t("bills.labels.printlabels")}
|
|
</Button>
|
|
</Space>
|
|
);
|
|
}
|