* chore: removed eslint-disable statements * refactor: removed unnecessary files and unintentional eslint-disable statements * refactor: removed eslint import/no-cycle error * fix: failing testcase * style: removed comments * fix: failing testcase --------- Co-authored-by: sohailfatima <23100065@lums.edu.pk> Co-authored-by: Fatima Sohail <68312464+sohailfatima@users.noreply.github.com>
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
import { RequestStatus } from './constants';
|
|
|
|
const blocksSlice = createSlice({
|
|
name: 'courseBlocks',
|
|
initialState: {
|
|
status: RequestStatus.IN_PROGRESS,
|
|
topics: {
|
|
// Maps topic id to the discussion course path and link
|
|
},
|
|
// List of chapter blocks in the course. Rest of the structure can be derived from children of topics
|
|
chapters: [],
|
|
// Mapping of block keys to block data
|
|
blocks: {},
|
|
},
|
|
reducers: {
|
|
fetchCourseBlocksRequest: (state) => (
|
|
{
|
|
...state,
|
|
status: RequestStatus.IN_PROGRESS,
|
|
}
|
|
),
|
|
fetchCourseBlocksSuccess: (state, { payload }) => (
|
|
{
|
|
...state,
|
|
status: RequestStatus.SUCCESSFUL,
|
|
topics: payload.topics,
|
|
chapters: payload.chapters,
|
|
blocks: payload.blocks,
|
|
}
|
|
),
|
|
fetchCourseBlocksFailed: (state) => (
|
|
{
|
|
...state,
|
|
status: RequestStatus.FAILED,
|
|
}
|
|
),
|
|
fetchCourseBlocksDenied: (state) => (
|
|
{
|
|
...state,
|
|
status: RequestStatus.DENIED,
|
|
}
|
|
),
|
|
},
|
|
});
|
|
|
|
export const {
|
|
fetchCourseBlocksRequest,
|
|
fetchCourseBlocksSuccess,
|
|
fetchCourseBlocksFailed,
|
|
fetchCourseBlocksDenied,
|
|
} = blocksSlice.actions;
|
|
|
|
export const blocksReducer = blocksSlice.reducer;
|