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;
