summaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-03-14 12:08:32 +0300
committereug-vs <eug-vs@keemail.me>2021-03-14 12:08:32 +0300
commit8e011b65f346386abe26afcce737dd59c5865988 (patch)
tree68e1159eea6ec6ea65740bf61e5ee1182883dae4 /src/containers
parentdfe13c7c061b4b2fd6dfde8e1c3c284d574ad8f2 (diff)
downloadcommercel-ui-8e011b65f346386abe26afcce737dd59c5865988.tar.gz
feat: add Waybills
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/ContractorForm.tsx1
-rw-r--r--src/containers/Service/ServiceContext.tsx1
-rw-r--r--src/containers/Service/ServiceForm.tsx3
-rw-r--r--src/containers/WaybillForm.tsx33
4 files changed, 36 insertions, 2 deletions
diff --git a/src/containers/ContractorForm.tsx b/src/containers/ContractorForm.tsx
index 4e83fae..c78ed9b 100644
--- a/src/containers/ContractorForm.tsx
+++ b/src/containers/ContractorForm.tsx
@@ -8,7 +8,6 @@ const ContractorForm: React.FC = () => {
<div className="max-w-lg">
<Input name="name" label="Название" />
<Input name="vatId" label="УНП" />
- <Input name="debt" type="number" label="Долг ($)" />
</div>
</Form>
);
diff --git a/src/containers/Service/ServiceContext.tsx b/src/containers/Service/ServiceContext.tsx
index 2602936..8f23d9d 100644
--- a/src/containers/Service/ServiceContext.tsx
+++ b/src/containers/Service/ServiceContext.tsx
@@ -6,6 +6,7 @@ export interface ServiceParams {
nameSingular: string;
tableFields: any[];
Form: React.FC<any>;
+ default: Record<string, any>;
}
const ServiceContext = React.createContext<ServiceParams>({
diff --git a/src/containers/Service/ServiceForm.tsx b/src/containers/Service/ServiceForm.tsx
index 273f5bd..62e4521 100644
--- a/src/containers/Service/ServiceForm.tsx
+++ b/src/containers/Service/ServiceForm.tsx
@@ -1,6 +1,7 @@
import React, { useContext } from 'react';
import { useParams, useHistory } from 'react-router-dom';
import { Formik } from 'formik';
+import _ from 'lodash';
import Page, { Action } from '../Page';
import hooks from '../../hooks/useAPIClient';
import { post, patch } from '../../requests';
@@ -32,7 +33,7 @@ const ServiceForm: React.FC = () => {
<Page title={id ? item?.name : `Новый ${service.nameSingular}`} actions={actions}>
{(!id || item) && (
<Formik
- initialValues={item || { name: '', debt: '', vatId: '' }}
+ initialValues={_.defaults(item, service.default)}
onSubmit={onSubmit}
>
<service.Form />
diff --git a/src/containers/WaybillForm.tsx b/src/containers/WaybillForm.tsx
new file mode 100644
index 0000000..e4d7d82
--- /dev/null
+++ b/src/containers/WaybillForm.tsx
@@ -0,0 +1,33 @@
+import React from 'react';
+import { Form, Field } from 'formik';
+import Input from '../components/Input';
+import hooks from '../hooks/useAPIClient';
+
+const WaybillForm: React.FC = () => {
+ const { data: contractors } = hooks.contractors.useList();
+ const { data: products } = hooks.products.useList();
+
+ return (
+ <Form id="form">
+ <div className="max-w-lg">
+ <Field name="operation" as="select">
+ <option value="in">Приход</option>
+ <option value="out">Расход</option>
+ </Field>
+ <Field name="contractorId" as="select">
+ {contractors?.map(contractor => (
+ <option value={contractor._id}>{contractor.name}</option>
+ ))}
+ </Field>
+ <Field name="productId" as="select">
+ {products?.map(product => (
+ <option value={product._id}>{product.name}</option>
+ ))}
+ </Field>
+ <Input name="quantity" type="number" label="Количество" />
+ </div>
+ </Form>
+ );
+};
+
+export default WaybillForm;