fix: BIG-148 items entries ordered by index.

This commit is contained in:
a.bouhuolia
2021-10-31 13:24:12 +02:00
parent cbce9f6d50
commit 9211e963c6
16 changed files with 200 additions and 94 deletions

View File

@@ -8,13 +8,14 @@ import { useEditableItemsEntriesColumns } from './components';
import {
saveInvoke,
compose,
updateTableCell,
updateMinEntriesLines,
updateAutoAddNewLine,
updateRemoveLineByIndex,
} from 'utils';
import { updateItemsEntriesTotal, useFetchItemRow } from './utils';
import { updateTableRow } from '../../utils';
import {
useFetchItemRow,
composeRowsOnNewRow,
composeRowsOnEditCell,
} from './utils';
/**
* Items entries table.
@@ -50,10 +51,7 @@ function ItemsEntriesTable({
itemType,
notifyNewRow: (newRow, rowIndex) => {
// Update the rate, description and quantity data of the row.
const newRows = compose(
updateItemsEntriesTotal,
updateTableRow(rowIndex, newRow),
)(rows);
const newRows = composeRowsOnNewRow(rowIndex, newRow, rows);
setRows(newRows);
onUpdateData(newRows);
@@ -66,11 +64,8 @@ function ItemsEntriesTable({
if (columnId === 'item_id') {
setItemRow({ rowIndex, columnId, itemId: value });
}
const newRows = compose(
updateAutoAddNewLine(defaultEntry, ['item_id']),
updateItemsEntriesTotal,
updateTableCell(rowIndex, columnId, value),
)(rows);
const composeEditCell = composeRowsOnEditCell(rowIndex, columnId);
const newRows = composeEditCell(value, defaultEntry, rows);
setRows(newRows);
onUpdateData(newRows);