feat: print action when click on print button

This commit is contained in:
Ahmed Bouhuolia
2024-05-23 19:39:23 +02:00
parent fe41f7976d
commit dc5bdf0b66
16 changed files with 239 additions and 64 deletions

View File

@@ -25,6 +25,7 @@ import {
import { useCustomersListContext } from './CustomersListProvider';
import { useRefreshCustomers } from '@/hooks/query/customers';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import withCustomers from './withCustomers';
import withCustomersActions from './withCustomersActions';
@@ -70,6 +71,10 @@ function CustomerActionsBar({
// Customers refresh action.
const { refresh } = useRefreshCustomers();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
const onClickNewCustomer = () => {
history.push('/customers/new');
};
@@ -109,6 +114,10 @@ function CustomerActionsBar({
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'customer' });
};
// Handle the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'Customer' });
};
return (
<DashboardActionsBar>
@@ -154,6 +163,14 @@ function CustomerActionsBar({
onClick={handleBulkDelete}
/>
</If>
<NavbarDivider />
<Button
className={Classes.MINIMAL}
icon={<Icon icon="print-16" iconSize={16} />}
text={<T id={'print'} />}
disabled={isExportPdfLoading}
onClick={handlePrintBtnClick}
/>
<Button
className={Classes.MINIMAL}
icon={<Icon icon="file-import-16" iconSize={16} />}