summaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/Service/ServiceContext.tsx3
-rw-r--r--src/containers/Service/ServiceForm.tsx5
-rw-r--r--src/containers/WaybillForm.tsx14
3 files changed, 11 insertions, 11 deletions
diff --git a/src/containers/Service/ServiceContext.tsx b/src/containers/Service/ServiceContext.tsx
index 8f23d9d..6c1a760 100644
--- a/src/containers/Service/ServiceContext.tsx
+++ b/src/containers/Service/ServiceContext.tsx
@@ -1,11 +1,12 @@
import React from 'react';
+import { FormikProps } from 'formik';
export interface ServiceParams {
route: string;
name: string;
nameSingular: string;
tableFields: any[];
- Form: React.FC<any>;
+ Form: React.FC<FormikProps>;
default: Record<string, any>;
}
diff --git a/src/containers/Service/ServiceForm.tsx b/src/containers/Service/ServiceForm.tsx
index 62e4521..e2dfef6 100644
--- a/src/containers/Service/ServiceForm.tsx
+++ b/src/containers/Service/ServiceForm.tsx
@@ -35,9 +35,8 @@ const ServiceForm: React.FC = () => {
<Formik
initialValues={_.defaults(item, service.default)}
onSubmit={onSubmit}
- >
- <service.Form />
- </Formik>
+ children={service.Form}
+ />
)}
</Page>
);
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"