diff options
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/ProductForm.tsx | 1 | ||||
-rw-r--r-- | src/containers/TransferForm.tsx | 44 | ||||
-rw-r--r-- | src/containers/WaybillPanel.tsx | 3 |
3 files changed, 45 insertions, 3 deletions
diff --git a/src/containers/ProductForm.tsx b/src/containers/ProductForm.tsx index f458372..060fbbb 100644 --- a/src/containers/ProductForm.tsx +++ b/src/containers/ProductForm.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { Form } from 'formik'; import Input from '../components/Input'; -import DatePicker from '../components/DatePicker'; const ProductForm: React.FC = () => { diff --git a/src/containers/TransferForm.tsx b/src/containers/TransferForm.tsx new file mode 100644 index 0000000..afb2dff --- /dev/null +++ b/src/containers/TransferForm.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { Form, FormikProps } from 'formik'; +import moment from 'moment'; +import Input from '../components/Input'; +import Select from '../components/Select'; +import hooks from '../hooks/useAPIClient'; + + +const mapper = (item: any) => ({ key: item._id, label: item.name }); + + +const TransferForm: React.FC<FormikProps> = ({ setFieldValue, values }) => { + const { data: contractors } = hooks.contractors.useList(); + + if (!values.date) setFieldValue('date', moment().format('YYYY-MM-DD')); + if (!values.contractorId && contractors) setFieldValue('contractorId', contractors[0]._id); + + return ( + <Form id="form"> + <div className="grid grid-cols-2"> + <Select + name="contractorId" + label="Контрагент" + options={contractors?.map(mapper)} + required + /> + <Input name="date" type="date" label="Дата" required /> + </div> + <div className="grid grid-cols-2"> + <Select + name="operation" + label="Операция" + options={[ + { key: 'in', label: 'Приход' }, + { key: 'out', label: 'Расход' }, + ]} + /> + <Input name="amount" type="number" label="Сумма" required /> + </div> + </Form> + ); +}; + +export default TransferForm; diff --git a/src/containers/WaybillPanel.tsx b/src/containers/WaybillPanel.tsx index d74ef1e..b90447e 100644 --- a/src/containers/WaybillPanel.tsx +++ b/src/containers/WaybillPanel.tsx @@ -1,8 +1,7 @@ import React from 'react'; import { useHistory } from 'react-router-dom'; -import Input from '../components/Input'; import Button from '../components/Button'; -import { patch, get, baseURL } from '../requests'; +import { patch, baseURL } from '../requests'; import { PanelProps } from './Service/ServiceContext'; |