diff options
Diffstat (limited to 'src/containers/WaybillForm.tsx')
-rw-r--r-- | src/containers/WaybillForm.tsx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/containers/WaybillForm.tsx b/src/containers/WaybillForm.tsx index bb8d9ab..1e3276f 100644 --- a/src/containers/WaybillForm.tsx +++ b/src/containers/WaybillForm.tsx @@ -1,12 +1,12 @@ import React from 'react'; -import { Form, Field } from 'formik'; +import { Form, FormikProps } from 'formik'; import Input from '../components/Input'; import Select from '../components/Select'; -import hooks from '../hooks/useAPIClient'; +import useOptions from '../hooks/useOptions'; -const WaybillForm: React.FC = () => { - const { data: contractors } = hooks.contractors.useList(); - const { data: products } = hooks.products.useList(); +const WaybillForm: React.FC<FormikProps> = ({ setFieldValue, values }) => { + const contractorOptions = useOptions('contractors', 'contractorId', values, setFieldValue); + const productOptions = useOptions('products', 'productId', values, setFieldValue); return ( <Form id="form"> @@ -14,12 +14,12 @@ const WaybillForm: React.FC = () => { <Select name="contractorId" label="Контрагент" - options={contractors?.map(c => ({ key: c._id, label: c.name }))} + options={contractorOptions} /> <Select name="productId" label="Товар" - options={products?.map(p => ({ key: p._id, label: p.name }))} + options={productOptions} /> <Select name="operation" |