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

@@ -27,6 +27,7 @@ import {
import { ItemAction, AbilitySubject } from '@/constants/abilityOption';
import { useItemsListContext } from './ItemsListProvider';
import { useRefreshItems } from '@/hooks/query/items';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import withItems from './withItems';
import withItemsActions from './withItemsActions';
@@ -60,11 +61,15 @@ function ItemsActionsBar({
addSetting,
// #withDialogActions
openDialog
openDialog,
}) {
// Items list context.
const { itemsViews, fields } = useItemsListContext();
//
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Items refresh action.
const { refresh } = useRefreshItems();
@@ -107,7 +112,12 @@ function ItemsActionsBar({
// Handle the export button click.
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'item' });
}
};
// Handle the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'Item' });
};
return (
<DashboardActionsBar>
@@ -153,7 +163,13 @@ function ItemsActionsBar({
onClick={handleBulkDelete}
/>
</If>
<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} />}
@@ -204,5 +220,5 @@ export default compose(
})),
withItemsActions,
withAlertActions,
withDialogActions
withDialogActions,
)(ItemsActionsBar);