// @ts-nocheck import React from 'react'; import intl from 'react-intl-universal'; import clsx from 'classnames'; import { useHistory } from 'react-router-dom'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, Position, PopoverInteractionKind, Popover, Menu, MenuItem, } from '@blueprintjs/core'; import { useCustomerDetailsDrawerContext } from './CustomerDetailsDrawerProvider'; import withAlertsActions from '@/containers/Alert/withAlertActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import withDrawerActions from '@/containers/Drawer/withDrawerActions'; import { DashboardActionsBar, Can, Icon, FormattedMessage as T, } from '@/components'; import { CustomerMoreMenuItem } from './utils'; import { AbilitySubject, SaleInvoiceAction, SaleEstimateAction, SaleReceiptAction, PaymentReceiveAction, CustomerAction, } from '@/constants/abilityOption'; import { compose } from '@/utils'; import { DRAWERS } from '@/constants/drawers'; /** * Customer details actions bar. */ function CustomerDetailsActionsBar({ // #withDialogActions openDialog, // #withAlertsActions openAlert, // #withDrawerActions closeDrawer, }) { const { contact, customerId } = useCustomerDetailsDrawerContext(); const history = useHistory(); // Handle new invoice button click. const handleNewInvoiceClick = () => { history.push('/invoices/new'); closeDrawer(DRAWERS.CUSTOMER_DETAILS); }; // Handle new receipt button click. const handleNewReceiptClick = () => { history.push('/receipts/new'); closeDrawer(DRAWERS.CUSTOMER_DETAILS); }; // Handle new payment receive button click. const handleNewPaymentClick = () => { history.push('/payment-received/new'); closeDrawer(DRAWERS.CUSTOMER_DETAILS); }; // Handle new estimate button click. const handleNewEstimateClick = () => { history.push('/estimates/new'); closeDrawer(DRAWERS.CUSTOMER_DETAILS); }; // Handles delete customer click. const handleDeleteCustomer = () => { openAlert(`customer-delete`, { contactId: customerId }); }; // Handles edit customer click. const handleEditContact = () => { history.push(`/customers/${customerId}/edit`); closeDrawer(DRAWERS.CUSTOMER_DETAILS); }; // Handle edit opening balance click. const handleEditOpeningBalance = () => { openDialog('customer-opening-balance', { customerId }); }; return ( } onClick={handleNewInvoiceClick} /> } onClick={handleNewEstimateClick} /> } onClick={handleNewReceiptClick} /> } onClick={handleNewPaymentClick} /> } minimal={true} interactionKind={PopoverInteractionKind.CLICK} position={Position.BOTTOM_LEFT} >