mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import React, { useMemo } from 'react';
|
|
import intl from 'react-intl-universal';
|
|
|
|
import FinancialSheet from 'components/FinancialSheet';
|
|
import { DataTable } from 'components';
|
|
import { useInventoryItemDetailsColumns } from './components';
|
|
import { useInventoryItemDetailsContext } from './InventoryItemDetailsProvider';
|
|
|
|
import { defaultExpanderReducer } from 'utils';
|
|
|
|
/**
|
|
* Inventory item detail table.
|
|
*/
|
|
export default function InventoryItemDetailsTable({
|
|
// #ownProps
|
|
companyName,
|
|
}) {
|
|
const {
|
|
inventoryItemDetails: { tableRows },
|
|
isInventoryItemDetailsLoading,
|
|
query,
|
|
} = useInventoryItemDetailsContext();
|
|
|
|
const columns = useInventoryItemDetailsColumns();
|
|
|
|
const expandedRows = useMemo(
|
|
() => defaultExpanderReducer(tableRows, 4),
|
|
[tableRows],
|
|
);
|
|
|
|
const rowClassNames = (row) => {
|
|
return [`row-type--${row.original.row_types}`];
|
|
};
|
|
|
|
return (
|
|
<FinancialSheet
|
|
name="inventory-item-details"
|
|
companyName={companyName}
|
|
sheetType={intl.get('inventory_item_details')}
|
|
loading={isInventoryItemDetailsLoading}
|
|
fromDate={query.from_date}
|
|
toDate={query.to_date}
|
|
>
|
|
<DataTable
|
|
className="bigcapital-datatable--financial-report"
|
|
columns={columns}
|
|
data={tableRows}
|
|
rowClassNames={rowClassNames}
|
|
noInitialFetch={true}
|
|
expandable={true}
|
|
expanded={expandedRows}
|
|
expandToggleColumn={1}
|
|
expandColumnSpace={0.8}
|
|
/>
|
|
</FinancialSheet>
|
|
);
|
|
}
|