// @ts-nocheck import React from 'react'; import { NavbarGroup, NavbarDivider, Button, Classes, Intent, Switch, Alignment, } from '@blueprintjs/core'; import { useHistory } from 'react-router-dom'; import { If, Icon, Can, FormattedMessage as T, DashboardActionViewsList, AdvancedFilterPopover, DashboardFilterButton, DashboardRowsHeightButton, DashboardActionsBar, } from '@/components'; import { useCustomersListContext } from './CustomersListProvider'; import { useRefreshCustomers } from '@/hooks/query/customers'; import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf'; import withCustomers from './withCustomers'; import withCustomersActions from './withCustomersActions'; import withAlertActions from '@/containers/Alert/withAlertActions'; import withSettingsActions from '@/containers/Settings/withSettingsActions'; import withSettings from '@/containers/Settings/withSettings'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { CustomerAction, AbilitySubject } from '@/constants/abilityOption'; import { compose } from '@/utils'; import { DialogsName } from '@/constants/dialogs'; /** * Customers actions bar. */ function CustomerActionsBar({ // #withCustomers customersSelectedRows = [], customersFilterConditions, // #withCustomersActions setCustomersTableState, accountsInactiveMode, // #withAlertActions openAlert, // #withSettings customersTableSize, // #withSettingsActions addSetting, // #withDialogActions openDialog, }) { // History context. const history = useHistory(); // Customers list context. const { customersViews, fields } = useCustomersListContext(); // Customers refresh action. const { refresh } = useRefreshCustomers(); // Exports pdf document. const { downloadAsync: downloadExportPdf } = useDownloadExportPdf(); const onClickNewCustomer = () => { history.push('/customers/new'); }; // Handle Customers bulk delete button click., const handleBulkDelete = () => { openAlert('customers-bulk-delete', { customersIds: customersSelectedRows }); }; const handleTabChange = (view) => { setCustomersTableState({ viewSlug: view ? view.slug : null, }); }; // Handle inactive switch changing. const handleInactiveSwitchChange = (event) => { const checked = event.target.checked; setCustomersTableState({ inactiveMode: checked }); }; // Handle click a refresh customers const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('customers', 'tableSize', size); }; // Handle import button click. const handleImportBtnClick = () => { history.push('/customers/import'); }; // Handle the export button click. const handleExportBtnClick = () => { openDialog(DialogsName.Export, { resource: 'customer' }); }; // Handle the print button click. const handlePrintBtnClick = () => { downloadExportPdf({ resource: 'Customer' }); }; return ( } onChange={handleTabChange} />