* Moving model-store into “generic” sub-directory. Also adding a README.md to explain what belongs in “generic” * Moving user-messages into “generic” sub-directory. * Moving PageLoading into “generic” sub-directory. * Moving “tabs” module into “generic” sub-directory. * Moving InstructorToolbar and MasqueradeWidget up to instructor-toolbar. The masquerade widget is a sub-module of instructor-toolbar. * Co-locating celebration APIs with celebration utils. Also adding an ADR about thunk/API naming conventions and making some other areas of the code adhere to it. * Moving courseware data (thunks, api) into the courseware module. Note that cousre-home/data/api still uses normalizeBlocks - this should be fixed so it’s not reaching across. Maybe we pull that particular API up top. This PR includes a few TODOs for things I saw, as well as a tiny bit of whitespace cleanup.
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/* eslint-disable no-param-reassign */
|
|
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
export const LOADING = 'loading';
|
|
export const LOADED = 'loaded';
|
|
export const FAILED = 'failed';
|
|
export const DENIED = 'denied';
|
|
|
|
const slice = createSlice({
|
|
name: 'courseware',
|
|
initialState: {
|
|
courseStatus: 'loading',
|
|
courseId: null,
|
|
sequenceStatus: 'loading',
|
|
sequenceId: null,
|
|
},
|
|
reducers: {
|
|
fetchCourseRequest: (state, { payload }) => {
|
|
state.courseId = payload.courseId;
|
|
state.courseStatus = LOADING;
|
|
},
|
|
fetchCourseSuccess: (state, { payload }) => {
|
|
state.courseId = payload.courseId;
|
|
state.courseStatus = LOADED;
|
|
},
|
|
fetchCourseFailure: (state, { payload }) => {
|
|
state.courseId = payload.courseId;
|
|
state.courseStatus = FAILED;
|
|
},
|
|
fetchCourseDenied: (state, { payload }) => {
|
|
state.courseId = payload.courseId;
|
|
state.courseStatus = DENIED;
|
|
},
|
|
fetchSequenceRequest: (state, { payload }) => {
|
|
state.sequenceId = payload.sequenceId;
|
|
state.sequenceStatus = LOADING;
|
|
},
|
|
fetchSequenceSuccess: (state, { payload }) => {
|
|
state.sequenceId = payload.sequenceId;
|
|
state.sequenceStatus = LOADED;
|
|
},
|
|
fetchSequenceFailure: (state, { payload }) => {
|
|
state.sequenceId = payload.sequenceId;
|
|
state.sequenceStatus = FAILED;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
fetchCourseRequest,
|
|
fetchCourseSuccess,
|
|
fetchCourseFailure,
|
|
fetchCourseDenied,
|
|
fetchSequenceRequest,
|
|
fetchSequenceSuccess,
|
|
fetchSequenceFailure,
|
|
} = slice.actions;
|
|
|
|
export const {
|
|
reducer,
|
|
} = slice;
|