import React from 'react'; import { Intent, Tag, Menu, MenuItem, MenuDivider, ProgressBar, Popover, Position, Button, } from '@blueprintjs/core'; import { FormattedMessage as T, useIntl } from 'react-intl'; import moment from 'moment'; import { round } from 'lodash'; import { Choose, If, Icon } from 'components'; import { Money, AppToaster } from 'components'; import { formatMessage } from 'services/intl'; import { safeCallback } from 'utils'; const calculateStatus = (paymentAmount, balanceAmount) => { return round(paymentAmount / balanceAmount, 2); }; export const statusAccessor = (row) => { return (
, }} />
); }; export const handleDeleteErrors = (errors) => { if ( errors.find( (error) => error.type === 'INVOICE_HAS_ASSOCIATED_PAYMENT_ENTRIES', ) ) { AppToaster.show({ message: formatMessage({ id: 'the_invoice_cannot_be_deleted', }), intent: Intent.DANGER, }); } if ( errors.find( (error) => error.type === 'INVOICE_AMOUNT_SMALLER_THAN_PAYMENT_AMOUNT', ) ) { AppToaster.show({ message: formatMessage({ id: 'the_payment_amount_that_received', }), intent: Intent.DANGER, }); } }; export function ActionsMenu({ payload: { onEdit, onDeliver, onDelete, onDrawer, onQuick }, row: { original }, }) { const { formatMessage } = useIntl(); return ( } text={formatMessage({ id: 'view_details' })} /> } text={formatMessage({ id: 'edit_invoice' })} onClick={safeCallback(onEdit, original)} /> } text={formatMessage({ id: 'mark_as_delivered' })} onClick={safeCallback(onDeliver, original)} /> } text={formatMessage({ id: 'add_payment' })} onClick={safeCallback(onQuick, original)} /> } text={formatMessage({ id: 'invoice_paper' })} onClick={safeCallback(onDrawer, original)} /> } /> ); } function ActionsCell(props) { return ( } position={Position.RIGHT_BOTTOM} >