From 2dffc2a4e683155e45b60c9240352ac07d251049 Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Tue, 3 Aug 2021 23:24:28 +0500 Subject: [PATCH] feat: Added custom ordering in listed course apps --- src/pages-and-resources/data/thunks.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages-and-resources/data/thunks.js b/src/pages-and-resources/data/thunks.js index 46471282ba..6d94f4ee15 100644 --- a/src/pages-and-resources/data/thunks.js +++ b/src/pages-and-resources/data/thunks.js @@ -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),