summaryrefslogtreecommitdiff
path: root/src/containers/WaybillForm.tsx
blob: fedc9c494d3bf83f5237447f233c8a0471982938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import React from 'react';
import { Form, FormikProps } from 'formik';
import Input from '../components/Input';
import Select from '../components/Select';
import useOptions from '../hooks/useOptions';

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">
      <Select
        name="contractorId"
        label="Контрагент"
        options={contractorOptions}
      />
      <Select
        name="productId"
        label="Товар"
        options={productOptions}
      />
      <Select
        name="operation"
        label="Операция"
        options={[
          { key: 'in', label: 'Приход' },
          { key: 'out', label: 'Расход' },
        ]}
      />
      <Input name="quantity" type="number" label="Количество" />
    </Form>
  );
};

export default WaybillForm;