// @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 { FormattedMessage as T, AdvancedFilterPopover, If, Icon, Can, DashboardActionViewsList, DashboardFilterButton, DashboardRowsHeightButton, DashboardActionsBar, FSelect, } from '@/components'; import { withEstimates } from './withEstimates'; import { withEstimatesActions } from './withEstimatesActions'; import { withSettings } from '@/containers/Settings/withSettings'; import { withSettingsActions } from '@/containers/Settings/withSettingsActions'; import { withDialogActions } from '@/containers/Dialog/withDialogActions'; import { useEstimatesListContext } from './EstimatesListProvider'; import { useRefreshEstimates, } from '@/hooks/query/estimates'; import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf'; import { useBulkDeleteEstimatesDialog } from './hooks/use-bulk-delete-estimates-dialog'; import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption'; import { compose } from '@/utils'; import { DialogsName } from '@/constants/dialogs'; import { withDrawerActions } from '@/containers/Drawer/withDrawerActions'; import { DRAWERS } from '@/constants/drawers'; import { isEmpty } from 'lodash'; import { BrandingThemeFormGroup, BrandingThemeSelectButton, } from '@/containers/BrandingTemplates/BrandingTemplatesSelectFields'; /** * Estimates list actions bar. */ function EstimateActionsBar({ // #withEstimateActions setEstimatesTableState, // #withEstimates estimatesFilterRoles, estimatesSelectedRows = [], // #withSettings estimatesTableSize, // #withDialogActions openDialog, // #withDrawerActions openDrawer, // #withSettingsActions addSetting, }) { const history = useHistory(); // Estimates list context. const { estimatesViews, fields } = useEstimatesListContext(); // Exports pdf document. const { downloadAsync: downloadExportPdf } = useDownloadExportPdf(); // Handle click a new sale estimate. const onClickNewEstimate = () => { history.push('/estimates/new'); }; // Estimates refresh action. const { refresh } = useRefreshEstimates(); // Handle tab change. const handleTabChange = (view) => { setEstimatesTableState({ viewSlug: view ? view.slug : null, }); }; // Handle click a refresh sale estimates const handleRefreshBtnClick = () => { refresh(); }; // Handle table row size change. const handleTableRowSizeChange = (size) => { addSetting('salesEstimates', 'tableSize', size); }; // Handle the import button click. const handleImportBtnClick = () => { history.push('/estimates/import'); }; // Handle the export button click. const handleExportBtnClick = () => { openDialog(DialogsName.Export, { resource: 'sale_estimate' }); }; // Handles the print button click. const handlePrintBtnClick = () => { downloadExportPdf({ resource: 'SaleEstimate' }); }; // Handle customize button clicl. const handleCustomizeBtnClick = () => { openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'SaleEstimate' }); }; const { openBulkDeleteDialog, isValidatingBulkDeleteEstimates, } = useBulkDeleteEstimatesDialog(); // Handle bulk estimates delete. const handleBulkDelete = () => { openBulkDeleteDialog(estimatesSelectedRows); }; if (!isEmpty(estimatesSelectedRows)) { return (