import React from 'react'; import { Intent, Tag, Menu, MenuItem, MenuDivider } from '@blueprintjs/core'; import intl from 'react-intl-universal'; import clsx from 'classnames'; import { SaleEstimateAction, AbilitySubject, } from '../../../../common/abilityOption'; import { CLASSES } from '../../../../common/classes'; import { FormatDateCell, FormattedMessage as T, Money, Choose, Icon, If, Can, } from 'components'; import { safeCallback } from 'utils'; /** * Status accessor. */ export const statusAccessor = (row) => ( ); /** * Actions menu. */ export function ActionsMenu({ row: { original }, payload: { onEdit, onDeliver, onReject, onApprove, onDelete, onDrawer, onConvert, onViewDetails, onPrint, }, }) { return ( } text={intl.get('view_details')} onClick={safeCallback(onViewDetails, original)} /> } text={intl.get('edit_estimate')} onClick={safeCallback(onEdit, original)} /> } text={intl.get('convert_to_invoice')} onClick={safeCallback(onConvert, original)} /> } text={intl.get('mark_as_delivered')} onClick={safeCallback(onDeliver, original)} /> } text={intl.get('mark_as_rejected')} onClick={safeCallback(onReject, original)} /> } text={intl.get('mark_as_approved')} onClick={safeCallback(onApprove, original)} /> } text={intl.get('mark_as_approved')} onClick={safeCallback(onApprove, original)} /> } text={intl.get('mark_as_rejected')} onClick={safeCallback(onReject, original)} /> } text={intl.get('print')} onClick={safeCallback(onPrint, original)} /> } /> ); } function AmountAccessor({ amount, currency_code }) { return ; } export function useEstiamtesTableColumns() { return React.useMemo( () => [ { id: 'estimate_date', Header: intl.get('estimate_date'), accessor: 'estimate_date', Cell: FormatDateCell, width: 140, className: 'estimate_date', clickable: true, textOverview: true, }, { id: 'customer', Header: intl.get('customer_name'), accessor: 'customer.display_name', width: 140, className: 'customer_id', clickable: true, textOverview: true, }, { id: 'expiration_date', Header: intl.get('expiration_date'), accessor: 'expiration_date', Cell: FormatDateCell, width: 140, className: 'expiration_date', clickable: true, textOverview: true, }, { id: 'estimate_number', Header: intl.get('estimate_number'), accessor: (row) => row.estimate_number ? `${row.estimate_number}` : null, width: 140, className: 'estimate_number', clickable: true, textOverview: true, }, { id: 'amount', Header: intl.get('amount'), accessor: AmountAccessor, width: 140, align: 'right', clickable: true, className: clsx(CLASSES.FONT_BOLD), }, { id: 'status', Header: intl.get('status'), accessor: (row) => statusAccessor(row), width: 140, className: 'status', clickable: true, }, { id: 'reference_no', Header: intl.get('reference_no'), accessor: 'reference', width: 90, className: 'reference', clickable: true, textOverview: true, }, ], [], ); }