Skip to content

Commit

Permalink
refactor: address feedback 1
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-i-am committed Nov 29, 2024
1 parent 4fa1da6 commit 9d98e90
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/features/Courses/ClassesPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion src/features/Courses/TableLayout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}) => (
<Row className="justify-content-center my-4">
<Col>
Expand Down
9 changes: 7 additions & 2 deletions src/features/Courses/data/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
21 changes: 19 additions & 2 deletions src/features/Courses/data/thunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand Down

0 comments on commit 9d98e90

Please sign in to comment.