feat: auto-complete warehouse transfer row.

This commit is contained in:
a.bouhuolia
2022-02-14 23:30:52 +02:00
parent 913245d202
commit bb56790ce9
7 changed files with 226 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react';
import intl from 'react-intl-universal';
import { find, get } from 'lodash';
import { Tooltip, Button, Intent, Position } from '@blueprintjs/core';
import {
@@ -43,6 +44,26 @@ export function ActionsCellRenderer({
);
}
function SourceWarehouseAccessorCell({ value, row: { original }, payload }) {
const warehouse = find(
original.warehouses,
(w) => w.warehouseId === payload.sourceWarehouseId,
);
return get(warehouse, 'warehouseQuantityFormatted', '0');
}
function DistentionWarehouseAccessorCell({
value,
row: { original },
payload,
}) {
const warehouse = find(
original.warehouses,
(w) => w.warehouseId === payload.distentionWarehouseId,
);
return get(warehouse, 'warehouseQuantityFormatted', '0');
}
/**
* Retrieves warehouse transfer table columns.
* @returns
@@ -82,6 +103,7 @@ export const useWarehouseTransferTableColumns = () => {
Header: 'Source Warehouse',
accessor: 'source_warehouse',
disableSortBy: true,
Cell: SourceWarehouseAccessorCell,
align: 'right',
width: 120,
},
@@ -89,6 +111,7 @@ export const useWarehouseTransferTableColumns = () => {
id: 'destination_warehouse',
Header: 'Destination Warehouse',
accessor: 'destination_warehouse',
Cell: DistentionWarehouseAccessorCell,
disableSortBy: true,
align: 'right',
width: 120,