- Assume that Learning Sequences is available (waffle has been removed) - Stop calling course blocks API, which provided mostly duplicated information now. - Refactor a bit to avoid needing to globally know which units exist in sequences. That is now provided just-in-time for only the current sequence. - Add /first and /last URLs that you can use instead of unit IDs in URL paths, in service of the above point. AA-1040 AA-1153
69 lines
1.9 KiB
JavaScript
69 lines
1.9 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,
|
|
sequenceMightBeUnit: false,
|
|
},
|
|
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;
|
|
state.sequenceMightBeUnit = false;
|
|
},
|
|
fetchSequenceSuccess: (state, { payload }) => {
|
|
state.sequenceId = payload.sequenceId;
|
|
state.sequenceStatus = LOADED;
|
|
state.sequenceMightBeUnit = false;
|
|
},
|
|
fetchSequenceFailure: (state, { payload }) => {
|
|
state.sequenceId = payload.sequenceId;
|
|
state.sequenceStatus = FAILED;
|
|
state.sequenceMightBeUnit = payload.sequenceMightBeUnit || false;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
fetchCourseRequest,
|
|
fetchCourseSuccess,
|
|
fetchCourseFailure,
|
|
fetchCourseDenied,
|
|
fetchSequenceRequest,
|
|
fetchSequenceSuccess,
|
|
fetchSequenceFailure,
|
|
fetchCourseRecommendationsRequest,
|
|
fetchCourseRecommendationsSuccess,
|
|
fetchCourseRecommendationsFailure,
|
|
} = slice.actions;
|
|
|
|
export const {
|
|
reducer,
|
|
} = slice;
|