import { Col, Row } from "reactstrap";
import React, { useEffect } from "react";
import ValidationField from "../../../Components/ValidationField/ValidationField";
import { useFormikContext } from "formik";
import { useModalState } from "../../../zustand/Modal";
import { notes } from "../../../types/App";

const Form = () => {
  const { isOpen } = useModalState((state) => state);

  const formik = useFormikContext();
  useEffect(() => {
    if (isOpen === "") {
      formik.setErrors({});
      formik?.resetForm();
    }
  }, [isOpen]);

  return (
    <Row className="w-100">
      <Col>
        <ValidationField
          name="date"
          label="date"
          placeholder="date"
          type="Date"
        />
        <ValidationField
          type="TextArea"
          name="content"
          placeholder="content"
          label="content"
        />
      </Col>
      <Col>
        <ValidationField
          name="type"
          label="type"
          placeholder="type"
          type="Select"
          option={notes}
        />
        <ValidationField
          placeholder="attachments"
          type="File"
          name="attachments"
          label="attachments"
        />
      </Col>
    </Row>
  );
};

export default Form;
