Skip to content

Commit

Permalink
feat: Added custom ordering in listed course apps
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid authored and mehaknasir committed Aug 11, 2021
1 parent 00426d6 commit 2dffc2a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages-and-resources/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import {
updateCourseAppsApiStatus,
} from './slice';

const COURSE_APPS_ORDER = [
'progress',
'discussion',
'teams',
'edxnotes',
'wiki',
'calculator',
'textbooks',
];

/* eslint-disable import/prefer-default-export */
export function fetchCourseApps(courseId) {
return async (dispatch) => {
Expand All @@ -19,6 +29,9 @@ export function fetchCourseApps(courseId) {
try {
const courseApps = await getCourseApps(courseId);

courseApps.sort((firstEl, secondEl) => (
COURSE_APPS_ORDER.indexOf(firstEl.id) - COURSE_APPS_ORDER.indexOf(secondEl.id)));

dispatch(addModels({ modelType: 'courseApps', models: courseApps }));
dispatch(fetchCourseAppsSuccess({
courseAppIds: courseApps.map(courseApp => courseApp.id),
Expand Down

0 comments on commit 2dffc2a

Please sign in to comment.