mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: FastField re-rendering.
fix: Allocate landed cost dialog.
This commit is contained in:
@@ -30,6 +30,7 @@ function ItemsEntriesTable({
|
||||
linesNumber,
|
||||
currencyCode,
|
||||
itemType, // sellable or purchasable
|
||||
landedCost = false
|
||||
}) {
|
||||
const [rows, setRows] = React.useState(initialEntries);
|
||||
const [rowItem, setRowItem] = React.useState(null);
|
||||
@@ -94,7 +95,7 @@ function ItemsEntriesTable({
|
||||
}, [entries, rows]);
|
||||
|
||||
// Editiable items entries columns.
|
||||
const columns = useEditableItemsEntriesColumns();
|
||||
const columns = useEditableItemsEntriesColumns({ landedCost });
|
||||
|
||||
// Handles the editor data update.
|
||||
const handleUpdateData = useCallback(
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
ItemsListCell,
|
||||
PercentFieldCell,
|
||||
NumericInputCell,
|
||||
CheckBoxFieldCell,
|
||||
} from 'components/DataTableCells';
|
||||
|
||||
/**
|
||||
@@ -90,27 +91,18 @@ export function IndexTableCell({ row: { index } }) {
|
||||
return <span>{index + 1}</span>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Landed cost cell.
|
||||
*/
|
||||
const LandedCostCell = ({
|
||||
row: { index },
|
||||
column: { id },
|
||||
cell: { value: initialValue },
|
||||
data,
|
||||
payload,
|
||||
}) => {
|
||||
return <Checkbox minimal={true} className="ml2" />;
|
||||
};
|
||||
|
||||
/**
|
||||
* Landed cost header cell.
|
||||
*/
|
||||
const LandedCostHeaderCell = () => {
|
||||
return (
|
||||
<>
|
||||
<T id={'cost'} />
|
||||
<Hint content={''} />
|
||||
<T id={'Landed'} />
|
||||
<Hint
|
||||
content={
|
||||
'This options allows you to be able to add additional cost eg. freight then allocate cost to the items in your bills.'
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -118,7 +110,7 @@ const LandedCostHeaderCell = () => {
|
||||
/**
|
||||
* Retrieve editable items entries columns.
|
||||
*/
|
||||
export function useEditableItemsEntriesColumns() {
|
||||
export function useEditableItemsEntriesColumns({ landedCost }) {
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
@@ -182,14 +174,19 @@ export function useEditableItemsEntriesColumns() {
|
||||
width: 100,
|
||||
className: 'total',
|
||||
},
|
||||
{
|
||||
Header: '',
|
||||
accessor: 'landed_cost',
|
||||
Cell: LandedCostCell,
|
||||
width: 70,
|
||||
disableSortBy: true,
|
||||
disableResizing: true,
|
||||
},
|
||||
...(landedCost
|
||||
? [
|
||||
{
|
||||
Header: LandedCostHeaderCell,
|
||||
accessor: 'landed_cost',
|
||||
Cell: CheckBoxFieldCell,
|
||||
width: 100,
|
||||
disableSortBy: true,
|
||||
disableResizing: true,
|
||||
className: 'landed-cost',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
Header: '',
|
||||
accessor: 'action',
|
||||
|
||||
Reference in New Issue
Block a user