import React from 'react'; import { Intent, Tag, Menu, MenuItem, MenuDivider, ProgressBar, Popover, Position, Button, } from '@blueprintjs/core'; import intl from 'react-intl-universal'; import { FormattedMessage as T } from 'components'; import moment from 'moment'; import { Choose, If, Icon } from 'components'; import { Money, AppToaster } from 'components'; import { formattedAmount, safeCallback, calculateStatus } from 'utils'; export const statusAccessor = (row) => { return (
{intl.get('overdue_by', { overdue: row.overdue_days })} {intl.get('due_in', { due: row.remaining_days })} {intl.get('day_partially_paid', { due: formattedAmount(row.due_amount, row.currency_code), })}
); }; export const handleDeleteErrors = (errors) => { if ( errors.find( (error) => error.type === 'INVOICE_HAS_ASSOCIATED_PAYMENT_ENTRIES', ) ) { AppToaster.show({ message: intl.get('the_invoice_cannot_be_deleted'), intent: Intent.DANGER, }); } if ( errors.find( (error) => error.type === 'INVOICE_AMOUNT_SMALLER_THAN_PAYMENT_AMOUNT', ) ) { AppToaster.show({ message: intl.get('the_payment_amount_that_received'), intent: Intent.DANGER, }); } }; export function ActionsMenu({ payload: { onEdit, onDeliver, onDelete, onDrawer, onQuick, onViewDetails }, row: { original }, }) { return ( } text={intl.get('view_details')} onClick={safeCallback(onViewDetails, original)} /> } text={intl.get('edit_invoice')} onClick={safeCallback(onEdit, original)} /> } text={intl.get('mark_as_delivered')} onClick={safeCallback(onDeliver, original)} /> } text={intl.get('add_payment')} onClick={safeCallback(onQuick, original)} /> } text={intl.get('invoice_paper')} onClick={safeCallback(onDrawer, original)} /> } /> ); } function ActionsCell(props) { return ( } position={Position.RIGHT_BOTTOM} >