From 2305464999fdccdb809ce425cda8346ddc3df493 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Wed, 17 Mar 2021 03:46:21 +0300
Subject: feat: adapt useOptions to the new logic

---
 src/containers/WaybillForm.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/containers/WaybillForm.tsx')

diff --git a/src/containers/WaybillForm.tsx b/src/containers/WaybillForm.tsx
index 2167d17..1297a0f 100644
--- a/src/containers/WaybillForm.tsx
+++ b/src/containers/WaybillForm.tsx
@@ -7,13 +7,16 @@ import Select from '../components/Select';
 import Paper from '../components/Paper';
 import useOptions from '../hooks/useOptions';
 
+
 const WaybillForm: React.FC<FormikProps> = ({ setFieldValue, values }) => {
   const [recordsNumber, setRecordsNumber] = useState<number>(values.records.length);
 
   const handleAddRecord = () => setRecordsNumber(v => v + 1);
 
-  const contractorOptions = useOptions('contractors', 'contractorId', values, setFieldValue);
-  const productOptions = useOptions('products', 'productId', values, setFieldValue);
+  const productInitFields = _.times(recordsNumber).map(index => `records.${index}.productId`);
+
+  const contractorOptions = useOptions('contractors', ['contractorId'], values, setFieldValue);
+  const productOptions = useOptions('products', productInitFields, values, setFieldValue);
 
   return (
     <Form id="form">
-- 
cgit v1.2.3

