import { Form } from "antd";
import Payments from "./Payments";
import { useEffect } from "react";

export default function NewForm({ totalCalculator, due, form }) {
  const [paymentForm] = Form.useForm();

  useEffect(() => {
    form.setFieldsValue({
      paidAmount: [
        {
          amount: due,
          paymentType: 1,
        },
      ],
    });
    totalCalculator();
  }, [due, form]);

  return (
    <Form
      form={paymentForm}
      initialValues={{
        paidAmount: [
          {
            amount: due,
            paymentType: 1,
          },
        ],
      }}>
      <Payments
        totalCalculator={totalCalculator}
        form={form}
        paymentForm={paymentForm}
      />
    </Form>
  );
}
