import React from 'react';
import { Form, Field } from 'formik';
import Input from '../components/Input';
import Select from '../components/Select';
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">
        <Select
          name="contractorId"
          label="Контрагент"
          options={contractors?.map(c => ({ key: c._id, label: c.name }))}
        />
        <Select
          name="productId"
          label="Товар"
          options={products?.map(p => ({ key: p._id, label: p.name }))}
        />
        <Select
          name="operation"
          label="Операция"
          options={[
            { key: 'in', label: 'Приход' },
            { key: 'out', label: 'Расход' },
          ]}
        />
        <Input name="quantity" type="number" label="Количество" />
      </div>
    </Form>
  );
};

export default WaybillForm;
