feat: estimate tooltip.

This commit is contained in:
elforjani13
2022-04-09 00:42:34 +02:00
parent 2ced5dc013
commit cc457e1e43

View File

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