From 2ff20a6b93a92f0cac6b9f5584e81e39407e51c5 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 14 Mar 2021 13:39:31 +0300 Subject: feat: display populated fields --- src/components/ListTable.tsx | 3 ++- src/services.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/ListTable.tsx b/src/components/ListTable.tsx index 5c1333a..c333698 100644 --- a/src/components/ListTable.tsx +++ b/src/components/ListTable.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import _ from 'lodash'; interface Field { key: string; @@ -28,7 +29,7 @@ const ListTable: React.FC = ({ items = [], fields, handleRowClick = () => className={`border-b hover:bg-gray-100 cursor-pointer ${index % 2 && 'bg-gray-50'}`} onClick={() => handleRowClick(index)} > - {fields.map(field => {item[field.key]})} + {fields.map(field => {_.get(item, field.key)})} ))} diff --git a/src/services.js b/src/services.js index b610aa9..b9c2ecf 100644 --- a/src/services.js +++ b/src/services.js @@ -37,8 +37,8 @@ const services: ServiceParams[] = [ nameSingular: 'Накладная', tableFields: [ { key: 'operation', label: 'Операция' }, - { key: 'productId', label: 'Товар' }, - { key: 'contractorId', label: 'Поставщик' }, + { key: 'product.name', label: 'Товар' }, + { key: 'contractor.name', label: 'Поставщик' }, { key: 'status', label: 'Статус' }, { key: 'quantity', label: 'Количество' }, ], -- cgit v1.2.3