mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
import React, { useMemo } from 'react';
|
|
import intl from 'react-intl-universal';
|
|
|
|
import { If } from 'components';
|
|
import { CellTextSpan } from 'components/Datatable/Cells';
|
|
import { useInventoryValuationContext } from './InventoryValuationProvider';
|
|
import FinancialLoadingBar from '../FinancialLoadingBar';
|
|
|
|
import { getColumnWidth } from 'utils';
|
|
import { Align } from 'common';
|
|
|
|
/**
|
|
* Retrieve inventory valuation table columns.
|
|
*/
|
|
export const useInventoryValuationTableColumns = () => {
|
|
// inventory valuation context
|
|
const {
|
|
inventoryValuation: { tableRows },
|
|
} = useInventoryValuationContext();
|
|
|
|
return useMemo(
|
|
() => [
|
|
{
|
|
Header: intl.get('item_name'),
|
|
accessor: (row) => (row.code ? `${row.name} - ${row.code}` : row.name),
|
|
className: 'name',
|
|
width: 240,
|
|
textOverview: true,
|
|
},
|
|
{
|
|
Header: intl.get('quantity'),
|
|
accessor: 'quantity_formatted',
|
|
Cell: CellTextSpan,
|
|
className: 'quantity_formatted',
|
|
width: getColumnWidth(tableRows, `quantity_formatted`, {
|
|
minWidth: 120,
|
|
}),
|
|
textOverview: true,
|
|
align: Align.Right,
|
|
},
|
|
{
|
|
Header: intl.get('asset_value'),
|
|
accessor: 'valuation_formatted',
|
|
Cell: CellTextSpan,
|
|
className: 'valuation',
|
|
width: getColumnWidth(tableRows, `valuation_formatted`, {
|
|
minWidth: 120,
|
|
}),
|
|
textOverview: true,
|
|
align: Align.Right,
|
|
},
|
|
{
|
|
Header: intl.get('average'),
|
|
accessor: 'average_formatted',
|
|
Cell: CellTextSpan,
|
|
className: 'average_formatted',
|
|
width: getColumnWidth(tableRows, `average_formatted`, {
|
|
minWidth: 120,
|
|
}),
|
|
textOverview: true,
|
|
align: Align.Right,
|
|
},
|
|
],
|
|
[tableRows],
|
|
);
|
|
};
|
|
|
|
/**
|
|
* inventory valuation progress loading bar.
|
|
*/
|
|
export function InventoryValuationLoadingBar() {
|
|
const { isFetching } = useInventoryValuationContext();
|
|
|
|
return (
|
|
<If condition={isFetching}>
|
|
<FinancialLoadingBar />
|
|
</If>
|
|
);
|
|
}
|