feat: Added custom ordering in listed course apps
This commit is contained in:
committed by
Mehak Nasir
parent
00426d65d5
commit
2dffc2a4e6
@@ -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) => {
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user