import useAxios from "axios-hooks";

export default function () {
  const url = `/learn/v1/instructor`;
  const [{ ...coursesData }, getCoursesData] = useAxios(
    { method: "GET" },
    { manual: true }
  );

  const handleGetCoursesData = async (params) => {
    await getCoursesData({
      url: `${url}/courses/`,
      params,
    });
  };
  const [{ ...coursesAffilateData }, getCoursesAffilateData] = useAxios(
    { method: "GET" },
    { manual: true }
  );

  const handleGetCoursesAffilateData = async (params, id) => {
    await getCoursesAffilateData({
      url: `/learn/v1/instructor/${id}/courses/`,
      params,
    });
  };

  const [{ ...remainingSlotData }, remainingSlot] = useAxios(
    { method: "GET" },
    { manual: true }
  );
  const handleremainingSlot = async () => {
    return remainingSlot({
      url: `${url}/teams/remaining_slot/`,
    });
  };

  const [{ ...coursePersonalData }, coursePersonal] = useAxios(
    { method: "GET" },
    { manual: true }
  );

  const handleGetCoursePersonal = async (params) => {
    await coursePersonal({
      url: `/learn/v1/courses/`,
      params,
    });
  };

  const [{ ...upcomingTestPersonalData }, upcomingTestPersonal] = useAxios(
    { method: "GET" },
    { manual: true }
  );

  const handleGetUpcomingTestPersonal = async (params) => {
    await upcomingTestPersonal({
      url: "/learn/v1/account/upcoming_tests/",
      params,
    });
  };
  const [{ ...storageSummaryData }, getStorageSummary] = useAxios(
    { method: "GET" },
    { manual: true }
  );

  const handleGetStorageSummary = async (id) => {
    await getStorageSummary({
      url: `/media/v1/instructor/${id}/filemanager/overview/`,
    });
  };

  return {
    handleGetUpcomingTestPersonal,
    upcomingTestPersonalData,
    handleGetCoursesAffilateData,
    handleGetCoursePersonal,
    coursePersonalData,
    coursesAffilateData,
    coursesData,
    handleGetCoursesData,
    handleremainingSlot,
    remainingSlotData,
    storageSummaryData,
    handleGetStorageSummary,
  };
}
