// @ts-nocheck import React from 'react'; import { Button, Classes, NavbarDivider, NavbarGroup, Intent, Alignment, Menu, MenuItem, Popover, PopoverInteractionKind, Position, } from '@blueprintjs/core'; import { useHistory } from 'react-router-dom'; import { Icon, FormattedMessage as T, AdvancedFilterPopover, DashboardFilterButton, DashboardRowsHeightButton, DashboardActionsBar, } from '@/components'; import { Can, If, DashboardActionViewsList } from '@/components'; import { SaleInvoiceAction, AbilitySubject } from '@/constants/abilityOption'; import { useRefreshInvoices } from '@/hooks/query/invoices'; import { useInvoicesListContext } from './InvoicesListProvider'; import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf'; import withInvoices from './withInvoices'; import withInvoiceActions from './withInvoiceActions'; import withSettings from '@/containers/Settings/withSettings'; import withSettingsActions from '@/containers/Settings/withSettingsActions'; import { compose } from '@/utils'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { DialogsName } from '@/constants/dialogs'; import withDrawerActions from '@/containers/Drawer/withDrawerActions'; import { DRAWERS } from '@/constants/drawers'; /** * Invoices table actions bar. */ function InvoiceActionsBar({ // #withInvoiceActions setInvoicesTableState, // #withInvoices invoicesFilterRoles, // #withSettings invoicesTableSize, // #withSettingsActions addSetting, // #withDialogsActions openDialog, // #withDrawerActions openDrawer, }) { const history = useHistory(); // Sale invoices list context. const { invoicesViews, invoicesFields } = useInvoicesListContext(); // Exports pdf document. const { downloadAsync: downloadExportPdf } = useDownloadExportPdf(); // Handle new invoice button click. const handleClickNewInvoice = () => { history.push('/invoices/new'); }; // Invoices refresh action. const { refresh } = useRefreshInvoices(); // Handle views tab change. const handleTabChange = (view) => { setInvoicesTableState({ viewSlug: view ? view.slug : null }); }; // Handle click a refresh sale invoices const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('salesInvoices', 'tableSize', size); }; // Handle the import button click. const handleImportBtnClick = () => { history.push('/invoices/import'); }; // Handle the export button click. const handleExportBtnClick = () => { openDialog(DialogsName.Export, { resource: 'sale_invoice' }); }; // Handles the print button click. const handlePrintBtnClick = () => { downloadExportPdf({ resource: 'SaleInvoice' }); }; // Handles the invoice customize button click. const handleCustomizeBtnClick = () => { openDrawer(DRAWERS.INVOICE_CUSTOMIZE); }; return (