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 { useIntl } from 'react-intl';
/**
* Actions menu.
*/
export function ActionsMenu({
row: { original },
payload: { onEdit, onDelete },
}) {
const { formatMessage } = useIntl();
return (
);
}
/**
* Actions cell.
*/
export function ActionsCell(props) {
return (
}
position={Position.RIGHT_BOTTOM}
>
} />
);
}
/**
* Avatar cell.
*/
export function AvatarCell(row) {
return {firstLettersArgs(row.display_name)};
}
/**
* Phone number accessor.
*/
export function PhoneNumberAccessor(row) {
return (
{row.work_phone}
{row.personal_phone}
);
}
/**
* Balance accessor.
*/
export function BalanceAccessor(row) {
return ;
}
/**
* Retrieve customers table columns.
*/
export function useCustomersTableColumns() {
const { formatMessage } = useIntl();
return useMemo(
() => [
{
id: 'avatar',
Header: '',
accessor: AvatarCell,
className: 'avatar',
width: 50,
disableResizing: true,
disableSortBy: true,
},
{
id: 'display_name',
Header: formatMessage({ id: 'display_name' }),
accessor: 'display_name',
className: 'display_name',
width: 150,
},
{
id: 'company_name',
Header: formatMessage({ id: 'company_name' }),
accessor: 'company_name',
className: 'company_name',
width: 150,
},
{
id: 'phone_number',
Header: formatMessage({ id: 'phone_number' }),
accessor: PhoneNumberAccessor,
className: 'phone_number',
width: 100,
},
{
id: 'receivable_balance',
Header: formatMessage({ id: 'receivable_balance' }),
accessor: BalanceAccessor,
className: 'receivable_balance',
width: 100,
},
{
id: 'actions',
Cell: ActionsCell,
className: 'actions',
width: 70,
disableResizing: true,
disableSortBy: true,
},
],
[formatMessage],
);
}