import React, { useState } from 'react'; import { Form, FormikProps } from 'formik'; import _ from 'lodash'; import Input from '../components/Input'; import Button from '../components/Button'; import Select from '../components/Select'; import Paper from '../components/Paper'; import useOptions from '../hooks/useOptions'; const WaybillForm: React.FC = ({ setFieldValue, values }) => { const [recordsNumber, setRecordsNumber] = useState(values.records.length); const handleAddRecord = () => setRecordsNumber(v => v + 1); const contractorOptions = useOptions('contractors', 'contractorId', values, setFieldValue); const productOptions = useOptions('products', 'productId', values, setFieldValue); return (
{_.times(recordsNumber).map(index => ( {values.records[index]?.price * values.records[index]?.quantity || 0} ))}
); }; export default WaybillForm;