import React, { useMemo } from 'react'; import { Button, Popover, Menu, MenuItem, MenuDivider, Position, Intent, } from '@blueprintjs/core'; import { Icon, Money } from 'components'; import { safeCallback } from 'utils'; import { firstLettersArgs } from 'utils'; import intl from 'react-intl-universal'; /** * Actions menu. */ export function ActionsMenu({ row: { original }, payload: { onEdit, onDelete, onDuplicate }, }) { return ( } text={intl.get('view_details')} /> } text={intl.get('edit_customer')} onClick={safeCallback(onEdit, original)} /> } text={intl.get('duplicate')} onClick={safeCallback(onDuplicate, original)} /> } text={intl.get('delete_customer')} intent={Intent.DANGER} onClick={safeCallback(onDelete, original)} /> ); } /** * Avatar cell. */ export function AvatarCell(row) { return {firstLettersArgs(row.display_name)}; } /** * Phone number accessor. */ export function PhoneNumberAccessor(row) { return
{row.work_phone}
; } /** * Balance accessor. */ export function BalanceAccessor(row) { return ; } /** * Retrieve customers table columns. */ export function useCustomersTableColumns() { return useMemo( () => [ { id: 'avatar', Header: '', accessor: AvatarCell, className: 'avatar', width: 50, disableResizing: true, disableSortBy: true, }, { id: 'display_name', Header: intl.get('display_name'), accessor: 'display_name', className: 'display_name', width: 150, }, { id: 'company_name', Header: intl.get('company_name'), accessor: 'company_name', className: 'company_name', width: 150, }, { id: 'work_phone', Header: intl.get('work_phone'), accessor: PhoneNumberAccessor, className: 'phone_number', width: 100, }, { id: 'balance', Header: intl.get('receivable_balance'), accessor: BalanceAccessor, className: 'receivable_balance', width: 100, }, ], [], ); }