import React from 'react'; import { useHistory } from 'react-router-dom'; import { Button, NavbarGroup, Classes, NavbarDivider, Intent, PopoverInteractionKind, Position, MenuItem, Menu, Popover, } from '@blueprintjs/core'; import clsx from 'classnames'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; import { useVendorDetailsDrawerContext } from './VendorDetailsDrawerProvider'; import withAlertsActions from 'containers/Alert/withAlertActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDialogActions from 'containers/Dialog/withDialogActions'; import { Can, Icon, FormattedMessage as T } from 'components'; import { VendorMoreMenuItem } from './utils'; import { AbilitySubject, SaleInvoiceAction, PaymentMadeAction, VendorAction, } from '../../../common/abilityOption'; import { safeCallback, compose } from 'utils'; /** * Vendor details actions bar. */ function VendorDetailsActionsBar({ // #withDialogActions openDialog, // #withAlertsActions openAlert, // #withDrawerActions closeDrawer, }) { const { vendorId } = useVendorDetailsDrawerContext(); const history = useHistory(); // Handle edit vendor. const onEditContact = () => { history.push(`/vendors/${vendorId}/edit`); closeDrawer('vendor-details-drawer'); }; // Handle delete vendor. const onDeleteContact = () => { openAlert(`vendor-delete`, { contactId: vendorId }); }; const handleNewInvoiceClick = () => { history.push('bills/new'); closeDrawer('vendor-details-drawer'); }; const handleNewPaymentClick = () => { history.push('payment-mades/new'); closeDrawer('vendor-details-drawer'); }; const handleEditOpeningBalance = () => { openDialog('vendor-opening-balance', { vendorId }); }; return ( } onClick={handleNewInvoiceClick} /> } onClick={handleNewPaymentClick} /> } minimal={true} interactionKind={PopoverInteractionKind.CLICK} position={Position.BOTTOM_LEFT} >