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 { useGetAllRegistrationRecord } from "../../../../../../api/registrationRecord";
import registration_recordSelect from "../../../../../../utils/registration_recordSelect";
import { useGetAllExam } from "../../../../../../api/exam";
import { useParams } from "react-router-dom";

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

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

  const { edu_class_id } = useParams();

  const { data: registration_record } = useGetAllRegistrationRecord({
    edu_class_id: edu_class_id,
    status: "active",
  });
  const { data: Exam } = useGetAllExam({});

  // console.log(registration_record,"registration_record");

  const recordSelect = registration_recordSelect(registration_record?.data);
  const ExamSelect = registration_recordSelect(Exam?.data);

  return (
    <Row className="w-100">
      <Col>
        <ValidationField
          placeholder="exam_id"
          label="exam_id"
          type="Select"
          option={ExamSelect}
          name="exam_id"
        />

        <ValidationField
          placeholder="mark"
          label="mark "
          name="value"
          type="NumberFormate"
        />
      </Col>

      <Col></Col>
    </Row>
  );
};

export default Form;
