// @ts-nocheck import React from 'react'; import { isEmpty, isUndefined } from 'lodash'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, Switch, Alignment, ProgressBar, ToastProps, Text, } from '@blueprintjs/core'; import clsx from 'classnames'; 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 { useHistory } from 'react-router-dom'; import { useRefreshAccounts } from '@/hooks/query/accounts'; import { useAccountsChartContext } from './AccountsChartProvider'; import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf'; import { useBulkDeleteAccountsDialog } from './hooks/use-bulk-delete-accounts-dialog'; 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'; /** * Accounts actions bar. */ function AccountsActionsBar({ // #withDialogActions openDialog, // #withAccounts accountsSelectedRows, accountsInactiveMode, accountsFilterConditions, // #withAlertActions openAlert, // #withAccountsTableActions setAccountsTableState, // #withSettings accountsTableSize, // #withSettingsActions addSetting, }) { const history = useHistory(); const { resourceViews, fields } = useAccountsChartContext(); // Exports pdf document. const { downloadAsync: downloadExportPdf } = useDownloadExportPdf(); // Accounts refresh action. const { refresh } = useRefreshAccounts(); // Bulk delete accounts dialog. const { openBulkDeleteDialog, isValidatingBulkDeleteAccounts, } = useBulkDeleteAccountsDialog(); // Handle bulk accounts delete. const handleBulkDelete = () => { openBulkDeleteDialog(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'); }; // Handle the export button click. const handleExportBtnClick = () => { openDialog(DialogsName.Export, { resource: 'account' }); }; // Handle the print button click. const handlePrintBtnClick = () => { downloadExportPdf({ resource: 'Account' }); }; // Handle click new account. const onClickNewAccount = () => { openDialog(DialogsName.AccountForm, {}); }; if (!isEmpty(accountsSelectedRows)) { return (