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

@@ -1,5 +1,4 @@
// @ts-nocheck
import React from 'react';
import {
Button,
Classes,
@@ -22,19 +21,20 @@ import {
DashboardRowsHeightButton,
DashboardActionsBar,
} from '@/components';
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
import withPaymentMade from './withPaymentMade';
import withPaymentMadeActions from './withPaymentMadeActions';
import withSettings from '@/containers/Settings/withSettings';
import withSettingsActions from '@/containers/Settings/withSettingsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
import { useRefreshPaymentMades } from '@/hooks/query/paymentMades';
import { PaymentMadeAction, AbilitySubject } from '@/constants/abilityOption';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { compose } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
import { compose } from '@/utils';
/**
* Payment made actions bar.
@@ -57,6 +57,10 @@ function PaymentMadeActionsBar({
}) {
const history = useHistory();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Payment receives list context.
const { paymentMadesViews, fields } = usePaymentMadesListContext();
@@ -67,31 +71,30 @@ function PaymentMadeActionsBar({
const handleClickNewPaymentMade = () => {
history.push('/payment-mades/new');
};
// Handle tab changing.
const handleTabChange = (viewSlug) => {
setPaymentMadesTableState({ viewSlug });
};
// Handle click a refresh payment receives.
const handleRefreshBtnClick = () => {
refresh();
};
// Handle table row size change.
const handleTableRowSizeChange = (size) => {
addSetting('billPayments', 'tableSize', size);
};
// Handle the import button click.
const handleImportBtnClick = () => {
history.push('/payment-mades/import');
};
// Handle the export button click.
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'bill_payment' });
};
// Handle the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'PaymentMade' });
};
return (
<DashboardActionsBar>
@@ -138,6 +141,8 @@ function PaymentMadeActionsBar({
className={Classes.MINIMAL}
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}