mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat(warehouseTransfer): add create & delete transfer & details.
This commit is contained in:
@@ -2,8 +2,15 @@ import React from 'react';
|
||||
|
||||
import { useWarehouseTransferTableColumns } from '../utils';
|
||||
import { DataTableEditable } from 'components';
|
||||
import { compose, saveInvoke, updateTableCell } from 'utils';
|
||||
|
||||
import {
|
||||
saveInvoke,
|
||||
compose,
|
||||
updateTableCell,
|
||||
updateMinEntriesLines,
|
||||
updateAutoAddNewLine,
|
||||
updateRemoveLineByIndex,
|
||||
orderingLinesIndexes,
|
||||
} from 'utils';
|
||||
/**
|
||||
* Warehouse transfer form entries table.
|
||||
*/
|
||||
@@ -11,6 +18,7 @@ export default function WarehouseTransferFormEntriesTable({
|
||||
// #ownProps
|
||||
items,
|
||||
entries,
|
||||
defaultEntry,
|
||||
onUpdateData,
|
||||
errors,
|
||||
}) {
|
||||
@@ -20,12 +28,30 @@ export default function WarehouseTransferFormEntriesTable({
|
||||
// Handle update data.
|
||||
const handleUpdateData = React.useCallback(
|
||||
(rowIndex, columnId, value) => {
|
||||
const newRows = compose(updateTableCell(rowIndex, columnId, value))(
|
||||
entries,
|
||||
);
|
||||
onUpdateData(newRows);
|
||||
const newRows = compose(
|
||||
// Update auto-adding new line.
|
||||
updateAutoAddNewLine(defaultEntry, ['item_id']),
|
||||
// Update the row value of the given row index and column id.
|
||||
updateTableCell(rowIndex, columnId, value),
|
||||
)(entries);
|
||||
|
||||
saveInvoke(onUpdateData, newRows);
|
||||
},
|
||||
[onUpdateData, entries],
|
||||
[entries, defaultEntry, onUpdateData],
|
||||
);
|
||||
// Handles click remove datatable row.
|
||||
const handleRemoveRow = React.useCallback(
|
||||
(rowIndex) => {
|
||||
const newRows = compose(
|
||||
// Ensure minimum lines count.
|
||||
updateMinEntriesLines(4, defaultEntry),
|
||||
// Remove the line by the given index.
|
||||
updateRemoveLineByIndex(rowIndex),
|
||||
)(entries);
|
||||
|
||||
saveInvoke(onUpdateData, newRows);
|
||||
},
|
||||
[entries, defaultEntry, onUpdateData],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -36,6 +62,8 @@ export default function WarehouseTransferFormEntriesTable({
|
||||
items,
|
||||
errors: errors || [],
|
||||
updateData: handleUpdateData,
|
||||
removeRow: handleRemoveRow,
|
||||
autoFocus: ['item_id', 0],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user