summaryrefslogtreecommitdiff
path: root/src/containers/WaybillForm.tsx
blob: 1e3276f1621ca266f884ca9b3896cf650712c8f4 (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
37
38
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">
      <div className="max-w-lg">
        <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="Количество" />
      </div>
    </Form>
  );
};

export default WaybillForm;