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

@@ -21,6 +21,7 @@ import {
} from '@/components';
import { useVendorsCreditNoteListContext } from './VendorsCreditNoteListProvider';
import { useResourceExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { VendorCreditAction, AbilitySubject } from '@/constants/abilityOption';
import withVendorsCreditNotesActions from './withVendorsCreditNotesActions';
@@ -60,35 +61,38 @@ function VendorsCreditNoteActionsBar({
const { VendorCreditsViews, fields, refresh } =
useVendorsCreditNoteListContext();
// Exports the given resource into pdf.
const { mutateAsync: exportPdf, isLoading: isExportPdfLoading } =
useResourceExportPdf();
// Handle click a new Vendor.
const handleClickNewVendorCredit = () => {
history.push('/vendor-credits/new');
};
// Handle view tab change.
const handleTabChange = (view) => {
setVendorCreditsTableState({ viewSlug: view ? view.slug : null });
};
// Handle click a refresh credit note.
const handleRefreshBtnClick = () => {
refresh();
};
// Handle table row size change.
const handleTableRowSizeChange = (size) => {
addSetting('vendorCredit', 'tableSize', size);
};
// Handle import button click.
const handleImportBtnClick = () => {
history.push('/vendor-credits/import');
};
// Handle the export button click.
const handleExportBtnClick = () => {
openDialog(DialogsName.Export, { resource: 'vendor_credit' });
};
// Handle the print button click.
const handlePrintBtnClick = () => {
exportPdf({ resource: 'VendorCredit' });
};
return (
<DashboardActionsBar>
@@ -127,6 +131,8 @@ function VendorsCreditNoteActionsBar({
className={Classes.MINIMAL}
icon={<Icon icon={'print-16'} iconSize={'16'} />}
text={<T id={'print'} />}
onClick={handlePrintBtnClick}
disabled={isExportPdfLoading}
/>
<Button
className={Classes.MINIMAL}