diff --git a/src/index.jsx b/src/index.jsx index e7103a0..14c1906 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -6,7 +6,7 @@ import { AppProvider, ErrorPage } from '@edx/frontend-platform/react'; import { subscribe, initialize, APP_INIT_ERROR, APP_READY, mergeConfig, } from '@edx/frontend-platform'; -import React from 'react'; +import React, { StrictMode } from 'react'; // eslint-disable-next-line import/no-unresolved import { createRoot } from 'react-dom/client'; import { Route, Routes, Outlet } from 'react-router-dom'; @@ -25,29 +25,31 @@ import Head from './head/Head'; const rootNode = createRoot(document.getElementById('root')); subscribe(APP_READY, () => { rootNode.render( - - - - -
-
- -
- - + + + + + +
+
+ +
+ + )} - > - } - /> - } /> - } /> - } /> - - - , + > + } + /> + } /> + } /> + } /> + + + + , ); }); diff --git a/src/notification-preferences/NotificationCoursesDropdown.jsx b/src/notification-preferences/NotificationCoursesDropdown.jsx index 28f393e..22f3756 100644 --- a/src/notification-preferences/NotificationCoursesDropdown.jsx +++ b/src/notification-preferences/NotificationCoursesDropdown.jsx @@ -1,12 +1,12 @@ -import React, { useCallback, useMemo } from 'react'; +import React, { useCallback, useEffect, useMemo } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useIntl } from '@edx/frontend-platform/i18n'; import { Dropdown } from '@openedx/paragon'; -import { SUCCESS_STATUS } from '../constants'; +import { IDLE_STATUS, SUCCESS_STATUS } from '../constants'; import { selectCourseList, selectCourseListStatus, selectSelectedCourseId } from './data/selectors'; -import { setSelectedCourse } from './data/thunks'; +import { fetchCourseList, setSelectedCourse } from './data/thunks'; import messages from './messages'; const NotificationCoursesDropdown = () => { @@ -24,6 +24,16 @@ const NotificationCoursesDropdown = () => { dispatch(setSelectedCourse(courseId)); }, [dispatch]); + const fetchCourses = useCallback((page = 1, pageSize = 99999) => { + dispatch(fetchCourseList(page, pageSize)); + }, [dispatch]); + + useEffect(() => { + if (courseListStatus === IDLE_STATUS) { + fetchCourses(); + } + }, [courseListStatus, fetchCourses]); + return ( courseListStatus === SUCCESS_STATUS && (
diff --git a/src/notification-preferences/data/thunks.js b/src/notification-preferences/data/thunks.js index 9e99d61..0041b84 100644 --- a/src/notification-preferences/data/thunks.js +++ b/src/notification-preferences/data/thunks.js @@ -97,7 +97,7 @@ const normalizePreferences = (responseData, courseId) => { return normalizedPreferences; }; -export const fetchCourseList = (page = 1, pageSize = 99999) => ( +export const fetchCourseList = (page, pageSize) => ( async (dispatch) => { try { dispatch(fetchCourseListFetching());