import React from 'react'; import intl from 'react-intl-universal'; import { useHistory } from 'react-router-dom'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, Position, PopoverInteractionKind, Popover, Menu, MenuItem, } from '@blueprintjs/core'; import clsx from 'classnames'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import { useCustomerDetailsDrawerContext } from './CustomerDetailsDrawerProvider'; import withAlertsActions from 'containers/Alert/withAlertActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions'; import { Can, Icon, FormattedMessage as T } from 'components'; import { AbilitySubject, Invoice_Abilities, Estimate_Abilities, Receipt_Abilities, Payment_Receive_Abilities, Customer_Abilities, } from '../../../common/abilityOption'; import { compose } from 'utils'; /** * Customer details actions bar. */ function CustomerDetailsActionsBar({ // #withAlertsActions openAlert, // #withDrawerActions closeDrawer, }) { const { contact, customerId } = useCustomerDetailsDrawerContext(); const history = useHistory(); // Handle new invoice button click. const handleNewInvoiceClick = () => { history.push('invoices/new'); closeDrawer('customer-details-drawer'); }; // Handle new receipt button click. const handleNewReceiptClick = () => { history.push('receipts/new'); closeDrawer('customer-details-drawer'); }; // Handle new payment receive button click. const handleNewPaymentClick = () => { history.push('payment-receives/new'); closeDrawer('customer-details-drawer'); }; // Handle new estimate button click. const handleNewEstimateClick = () => { history.push('estimates/new'); closeDrawer('customer-details-drawer'); }; const handleDeleteCustomer = () => { openAlert(`customer-delete`, { contactId: customerId }); }; const handleEditContact = () => { history.push(`/customers/${customerId}/edit`); closeDrawer('customer-details-drawer'); }; return ( } onClick={handleNewInvoiceClick} /> } onClick={handleNewEstimateClick} /> } onClick={handleNewReceiptClick} /> } onClick={handleNewPaymentClick} /> } minimal={true} interactionKind={PopoverInteractionKind.CLICK} position={Position.BOTTOM_LEFT} >