// @ts-nocheck import React from 'react'; import { isEmpty } from 'lodash'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, Switch, Alignment, } from '@blueprintjs/core'; import { AdvancedFilterPopover, If, Can, Icon, FormattedMessage as T, DashboardActionViewsList, DashboardFilterButton, DashboardRowsHeightButton, DashboardActionsBar, } from '@/components'; import { AccountAction, AbilitySubject } from '@/constants/abilityOption'; import { DialogsName } from '@/constants/dialogs'; import { useRefreshAccounts } from '@/hooks/query/accounts'; import { useAccountsChartContext } from './AccountsChartProvider'; import withAccounts from './withAccounts'; import withAccountsTableActions from './withAccountsTableActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import withAlertActions from '@/containers/Alert/withAlertActions'; import withSettings from '@/containers/Settings/withSettings'; import withSettingsActions from '@/containers/Settings/withSettingsActions'; import { compose } from '@/utils'; import { useHistory } from 'react-router-dom'; /** * Accounts actions bar. */ function AccountsActionsBar({ // #withDialogActions openDialog, // #withAccounts accountsSelectedRows, accountsInactiveMode, accountsFilterConditions, // #withAlertActions openAlert, // #withAccountsTableActions setAccountsTableState, // #ownProps onFilterChanged, // #withSettings accountsTableSize, // #withSettingsActions addSetting, }) { const { resourceViews, fields } = useAccountsChartContext(); const history = useHistory(); const onClickNewAccount = () => { openDialog(DialogsName.AccountForm, {}); }; // Accounts refresh action. const { refresh } = useRefreshAccounts(); // Handle bulk accounts delete. const handleBulkDelete = () => { openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows }); }; // Handle bulk accounts activate. const handelBulkActivate = () => { openAlert('accounts-bulk-activate', { accountsIds: accountsSelectedRows }); }; // Handle bulk accounts inactivate. const handelBulkInactive = () => { openAlert('accounts-bulk-inactivate', { accountsIds: accountsSelectedRows, }); }; // Handle tab changing. const handleTabChange = (view) => { setAccountsTableState({ viewSlug: view ? view.slug : null }); }; // Handle inactive switch changing. const handleInactiveSwitchChange = (event) => { const checked = event.target.checked; setAccountsTableState({ inactiveMode: checked }); }; // Handle click a refresh accounts const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('accounts', 'tableSize', size); }; // handle the import button click. const handleImportBtnClick = () => { history.push('/accounts/import'); }; return ( } views={resourceViews} onChange={handleTabChange} />