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

@@ -35,6 +35,7 @@ import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
import { useRefreshPaymentReceive } from '@/hooks/query/paymentReceives';
import { compose } from '@/utils';
import { DialogsName } from '@/constants/dialogs';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
/**
* Payment receives actions bar.
@@ -61,6 +62,10 @@ function PaymentReceiveActionsBar({
// Payment receives list context.
const { paymentReceivesViews, fields } = usePaymentReceivesListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Handle new payment button click.
const handleClickNewPaymentReceive = () => {
history.push('/payment-receives/new');
@@ -91,6 +96,10 @@ function PaymentReceiveActionsBar({
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'payment_receive' });
};
// Handles the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'PaymentReceive' });
};
return (
<DashboardActionsBar>
@@ -137,6 +146,8 @@ function PaymentReceiveActionsBar({
className={Classes.MINIMAL}
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}