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

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

  useEffect(() => {
    if (isOpen === "") {
      formik.setErrors({});
      // formik.resetForm();
    }
    if (isOpen === "isSuccess") {
      formik.setErrors({});
      formik.resetForm();
    }
  }, [isOpen]);

  return (
    <Row className="w-100">
      <Col>
        <ValidationField placeholder="content" label="content" name="content" />

        <ValidationField
          placeholder="date"
          label="date"
          type="Date"
          name="date"
        />
      </Col>

      <Col>
        <ValidationField
          placeholder="type"
          label="type"
          type="Select"
          option={notes}
          name="type"
        />

        <ValidationField
          placeholder="attachments"
          label="attachments"
          type="MaltyFile"
          name="attachments"
        />
      </Col>
    </Row>
  );
};

export default Form;
