* Updating dependencies and removing unneeded ones. * Fixing broken IntlProvider attribute in ProctoredExamSettings test. * package-lock.json was out of sync - checking it in. * Initializing an empty redux store. * Adding model-store from frontend-app-learning. This will let us save data from the server in a normalized way in redux, reducing boilerplate in React components. * Fixing paragon button usage. (also just organizing the imports while I was there…) * Using paragon button instead of an anchor tag. For the “New Page” button in the pages & resources view. * Add API, reducers, and thunks to add course detail data into redux. Subsequent PR will use this to store course detail data for use across different pages in the application. * Prep work to add CourseAuthoringPage component. Decided the course-detail sub-directory didn’t make much sense, given component structure, and moved it up to src. These functions will be used in a CourseAuthoringPage component to load course detail data and display the Header and Footer in one common place, wrapping all the existing course authoring pages (proctoring and pages & resources) It will also replace LmsApiService.js * Minor style refactorings. (This commit had originally made some changes to how courseId was passed in to these two components, but I decided to back it out… but the style stuff is worth adding as a fixed nit.) * Refactor course detail loading and top-level course authoring components This commit does a few things: - Factors course detail data loading out of the Header. - Loads that data in CourseAuthoringPage instead, adding it to redux and then passing it to the Header from there. - Deletes LmsApiService, which is no longer used. - Changes the route paths to be more canonical and entity-oriented, i.e., the first part of the route is the course, followed by the specific page about that course to load, rather than the other way around. This more naturally allows us to use react-router to extract the common course detail loading code that only depends on the courseId. * Refactoring routes code a bit to pass courseId into components Didn’t like how CourseAuthoringPage, LegacyProctoringRoute, and CourseAuthoringRoutes all reached into the parent route to find the courseId, so passed it in instead. * Updating README with more detail on routes in the MFE.
29 lines
541 B
JavaScript
29 lines
541 B
JavaScript
/* eslint-disable no-param-reassign */
|
|
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
export const LOADING = 'LOADING';
|
|
export const LOADED = 'LOADED';
|
|
export const FAILED = 'FAILED';
|
|
|
|
const slice = createSlice({
|
|
name: 'courseDetail',
|
|
initialState: {
|
|
courseId: null,
|
|
status: null,
|
|
},
|
|
reducers: {
|
|
updateStatus: (state, { payload }) => {
|
|
state.courseId = payload.courseId;
|
|
state.status = payload.status;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
updateStatus,
|
|
} = slice.actions;
|
|
|
|
export const {
|
|
reducer,
|
|
} = slice;
|