import React, { useEffect } from "react";
import { useAddStudent } from "../api/student";
import { useAddTeacher } from "../api/teacher";

// Function to create a student object
const createTeacher = () => {
  const randomNum = Math.floor(Math.random() * 10000); // Generate a random number

  return {
    name: `name${randomNum}`,
    contact_information: `contact_information${randomNum}`,
    address: `address${randomNum}`,
  };
};

const CreateTeacher = ({ number_of_user }: { number_of_user: number }) => {
  const { mutate } = useAddTeacher();

  useEffect(() => {
    for (let index = 0; index < number_of_user; index++) {
      const newStudent = createTeacher();

      // Call mutate to add the student
      mutate(newStudent);
    }
  }, [number_of_user, mutate]);

  return null; // or return some JSX if needed
};

export default CreateTeacher;
