diff --git a/src/features/Courses/ClassesPage/index.jsx b/src/features/Courses/ClassesPage/index.jsx index 3c57b4d..41b165e 100644 --- a/src/features/Courses/ClassesPage/index.jsx +++ b/src/features/Courses/ClassesPage/index.jsx @@ -18,7 +18,7 @@ const ClassesPage = () => { const { classesTable, table } = useSelector((state) => state.courses); const history = useHistory(); - const masterCourse = table.data.find((c) => extractLastPathSegment(c.url) === courseId); + const masterCourse = table.data.find((course) => extractLastPathSegment(course.url) === courseId); useEffect(() => { if (!masterCourse) { diff --git a/src/features/Courses/TableLayout/index.jsx b/src/features/Courses/TableLayout/index.jsx index 70873c1..a199e04 100644 --- a/src/features/Courses/TableLayout/index.jsx +++ b/src/features/Courses/TableLayout/index.jsx @@ -6,7 +6,14 @@ import { import './index.scss'; const TableLayout = ({ - data, columns, count, numPages, handleChangeSelectedCourses, isLoading, actionButton, handleRefetchData, + data, + columns, + count, + numPages, + handleChangeSelectedCourses, + isLoading, + actionButton, + handleRefetchData, }) => ( diff --git a/src/features/Courses/data/slice.js b/src/features/Courses/data/slice.js index 092e7c8..23646ac 100644 --- a/src/features/Courses/data/slice.js +++ b/src/features/Courses/data/slice.js @@ -59,8 +59,13 @@ export const coursesSlice = createSlice({ }); export const { - updateCoursesDataRequest, updateCoursesDataSuccess, updateCoursesDataFailed, - updateCourseClassesDataRequest, updateCourseClassesDataSuccess, updateCourseClassesDataFailed, resetCourseClassesData, + updateCoursesDataRequest, + updateCoursesDataSuccess, + updateCoursesDataFailed, + updateCourseClassesDataRequest, + updateCourseClassesDataSuccess, + updateCourseClassesDataFailed, + resetCourseClassesData, } = coursesSlice.actions; export const { reducer } = coursesSlice; diff --git a/src/features/Courses/data/thunk.js b/src/features/Courses/data/thunk.js index 89c4da8..9f143df 100644 --- a/src/features/Courses/data/thunk.js +++ b/src/features/Courses/data/thunk.js @@ -4,8 +4,12 @@ import { camelCaseObject } from '@edx/frontend-platform'; import { fetchLicensedCourses, fetchCoursesClasses } from 'features/Courses/data/api'; import { - updateCoursesDataRequest, updateCoursesDataSuccess, updateCoursesDataFailed, - updateCourseClassesDataRequest, updateCourseClassesDataSuccess, updateCourseClassesDataFailed, + updateCoursesDataRequest, + updateCoursesDataSuccess, + updateCoursesDataFailed, + updateCourseClassesDataRequest, + updateCourseClassesDataSuccess, + updateCourseClassesDataFailed, } from 'features/Courses/data/slice'; function fetchCoursesData(launchId) { @@ -22,6 +26,19 @@ function fetchCoursesData(launchId) { }; } +/** + * Fetches CCX courses for a specific master course. + * + * Dispatches a request action to update the classes data status to loading. + * It then attempts to fetch the classes data for a given course using the provided launch ID and parameters. + * If successful, it dispatches a success action with the fetched data. + * In case of failure, it dispatches a failure action and logs the error. + * + * @param {string} launchId - The launch ID for the request. + * @param {Object} params - Additional parameters for the request. + * @param {string} params.courseId - The course ID for which to fetch the classes data. + * @returns {Function} A thunk that handles fetching course classes data and dispatching actions. + */ function fetchCourseClassesData(launchId, params) { return async (dispatch) => { dispatch(updateCourseClassesDataRequest());