// @ts-nocheck import React, { useState } from 'react'; import { Button, Classes, NavbarDivider, NavbarGroup, Intent, Alignment, } from '@blueprintjs/core'; import { useHistory } from 'react-router-dom'; import { If, Can, Icon, FormattedMessage as T, DashboardActionViewsList, DashboardFilterButton, AdvancedFilterPopover, DashboardRowsHeightButton, DashboardActionsBar, } from '@/components'; import { BillAction, AbilitySubject } from '@/constants/abilityOption'; 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 { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf'; import { useBulkDeleteBillsDialog } from './hooks/use-bulk-delete-bills-dialog'; import { compose } from '@/utils'; import { DialogsName } from '@/constants/dialogs'; import { isEmpty } from 'lodash'; /** * Bills actions bar. */ function BillActionsBar({ // #withBillsActions setBillsTableState, // #withBills billsConditionsRoles, billsSelectedRows, // #withSettings billsTableSize, // #withSettingsActions addSetting, // #withDialogActions openDialog, }) { const history = useHistory(); // Bills refresh action. const { refresh } = useRefreshBills(); // Bills list context. const { billsViews, fields } = useBillsListContext(); // Exports pdf document. const { downloadAsync: downloadExportPdf } = useDownloadExportPdf(); // Handle click a new bill. const handleClickNewBill = () => { history.push('/bills/new'); }; // Handle tab change. const handleTabChange = (view) => { setBillsTableState({ viewSlug: view ? view.slug : null, }); }; // Handle click a refresh bills 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 = () => { downloadExportPdf({ resource: 'Bill' }); }; const { openBulkDeleteDialog, isValidatingBulkDeleteBills, } = useBulkDeleteBillsDialog(); // Handle bulk delete. const handleBulkDelete = () => { openBulkDeleteDialog(billsSelectedRows); }; if (!isEmpty(billsSelectedRows)) { return (