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

@@ -29,14 +29,15 @@ import withReceipts from './withReceipts';
import withReceiptsActions from './withReceiptsActions';
import withSettings from '@/containers/Settings/withSettings';
import withSettingsActions from '@/containers/Settings/withSettingsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useReceiptsListContext } from './ReceiptsListProvider';
import { useRefreshReceipts } from '@/hooks/query/receipts';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { SaleReceiptAction, AbilitySubject } from '@/constants/abilityOption';
import { compose } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
import { compose } from '@/utils';
/**
* Receipts actions bar.
@@ -62,6 +63,9 @@ function ReceiptActionsBar({
// Sale receipts list context.
const { receiptsViews, fields } = useReceiptsListContext();
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Handle new receipt button click.
const onClickNewReceipt = () => {
history.push('/receipts/new');
@@ -95,6 +99,10 @@ function ReceiptActionsBar({
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'sale_receipt' });
};
// Handle print button click.
const handlePrintButtonClick = () => {
exportPdf({ resource: 'SaleReceipt' });
};
return (
<DashboardActionsBar>
@@ -143,8 +151,9 @@ function ReceiptActionsBar({
className={Classes.MINIMAL}
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintButtonClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}
icon={<Icon icon={'file-import-16'} />}