import React from 'react'; import intl from 'react-intl-universal'; import { FormatNumberCell, TextOverviewTooltipCell } from '../../../components'; import { getColumnWidth } from 'utils'; import { useEstimateDetailDrawerContext } from './EstimateDetailDrawerProvider'; /** * Retrieve table columns of estimate readonly entries details. */ export const useEstimateReadonlyEntriesColumns = () => { // estimate details drawer context. const { estimate: { entries }, } = useEstimateDetailDrawerContext(); return React.useMemo( () => [ { Header: intl.get('product_and_service'), accessor: 'item.name', Cell: TextOverviewTooltipCell, width: 150, className: 'name', disableSortBy: true, textOverview: true, }, { Header: intl.get('description'), accessor: 'description', Cell: TextOverviewTooltipCell, className: 'description', disableSortBy: true, textOverview: true, }, { Header: intl.get('quantity'), accessor: 'quantity', Cell: FormatNumberCell, width: getColumnWidth(entries, 'quantity', { minWidth: 60, magicSpacing: 5, }), align: 'right', disableSortBy: true, textOverview: true, }, { Header: intl.get('rate'), accessor: 'rate', Cell: FormatNumberCell, width: getColumnWidth(entries, 'rate', { minWidth: 60, magicSpacing: 5, }), align: 'right', disableSortBy: true, textOverview: true, }, { Header: intl.get('amount'), accessor: 'amount', Cell: FormatNumberCell, width: getColumnWidth(entries, 'amount', { minWidth: 60, magicSpacing: 5, }), align: 'right', disableSortBy: true, textOverview: true, }, ], [], ); };