import { useQuery } from 'react-query';

import { getCourseOnPath } from 'src/pages/dashboard/Learning/Courses/services';

import { coursesKeys } from '../queries';

const useCheckCourseOnPath = (courseId: number | undefined) => {
  return useQuery({
    queryKey: coursesKeys.courseOnPath(courseId!),
    queryFn: () => {
      if (!courseId) throw new Error('Course ID is required');
      return getCourseOnPath(courseId);
    },
    enabled: false,
    select: response => response?.data,
  });
};

export default useCheckCourseOnPath;
