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

@@ -28,11 +28,13 @@ import withBills from './withBills';
import withBillsActions from './withBillsActions';
import withSettings from '@/containers/Settings/withSettings';
import withSettingsActions from '@/containers/Settings/withSettingsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { useBillsListContext } from './BillsListProvider';
import { useRefreshBills } from '@/hooks/query/bills';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { compose } from '@/utils';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
/**
@@ -62,11 +64,14 @@ function BillActionsBar({
// Bills list context.
const { billsViews, fields } = useBillsListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Handle click a new bill.
const handleClickNewBill = () => {
history.push('/bills/new');
};
// Handle tab change.
const handleTabChange = (view) => {
setBillsTableState({
@@ -77,21 +82,22 @@ function BillActionsBar({
const handleRefreshBtnClick = () => {
refresh();
};
// Handle table row size change.
const handleTableRowSizeChange = (size) => {
addSetting('bills', 'tableSize', size);
};
// Handle the import button click.
const handleImportBtnClick = () => {
history.push('/bills/import');
};
// Handle the export button click.
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'bill' });
};
// Handle the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'Bill' });
};
return (
<DashboardActionsBar>
@@ -133,13 +139,15 @@ function BillActionsBar({
icon={<Icon icon={'trash-16'} iconSize={16} />}
text={<T id={'delete'} />}
intent={Intent.DANGER}
// 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}
@@ -153,7 +161,6 @@ function BillActionsBar({
text={<T id={'export'} />}
onClick={handleExportBtnClick}
/>
<NavbarDivider />
<DashboardRowsHeightButton
initialValue={billsTableSize}