-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from abinth11/bug-fixes-and-updates
Bug fixes and updates
- Loading branch information
Showing
11 changed files
with
95 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
import { RootState } from "../store"; | ||
import { CourseInterface } from "../../types/course"; // Corrected import path | ||
|
||
const initialState = { | ||
data: { | ||
courseId: "", | ||
}, | ||
interface InitialState { | ||
course: CourseInterface | null; | ||
} | ||
|
||
const initialState: InitialState = { | ||
course: null, | ||
}; | ||
|
||
const courseSlice = createSlice({ | ||
name: "course", | ||
initialState, | ||
reducers: { | ||
setCourseId(state, action: PayloadAction<{ courseId: string }>) { | ||
state.data = { | ||
courseId: action.payload.courseId, | ||
}; | ||
setCourse(state, action: PayloadAction<{ course: CourseInterface }>) { | ||
state.course = action.payload.course; | ||
}, | ||
clearCourseId(state) { | ||
state.data = { | ||
courseId: "", | ||
}; | ||
clearCourse(state) { | ||
state.course = null; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setCourseId, clearCourseId } = courseSlice.actions; | ||
|
||
export const selectCourseId = (state: RootState) => state.course.data.courseId; | ||
export const { setCourse, clearCourse } = courseSlice.actions; | ||
|
||
export const selectCourse = (state: RootState) => state.course.course | ||
|
||
export const courseReducer = courseSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import { configureStore,combineReducers } from "@reduxjs/toolkit"; | ||
import { authReducer } from "./reducers/authSlice"; | ||
import { courseReducer } from "./reducers/courseSlice"; | ||
import { studentReducer } from "./reducers/studentSlice"; | ||
import { helperReducer } from "./reducers/helperSlice"; | ||
import { instructorReducer } from "./reducers/instructorSlice"; | ||
import * as reduxThunk from "redux-thunk/extend-redux"; | ||
export const store = configureStore({ | ||
reducer: { | ||
auth: authReducer, | ||
course: courseReducer, | ||
student: studentReducer, | ||
instructor: instructorReducer, | ||
helper: helperReducer, | ||
}, | ||
import { persistStore, persistReducer } from 'redux-persist'; | ||
import storage from 'redux-persist/lib/storage'; | ||
|
||
const persistConfig = { | ||
key: 'root', // Key to use for storing data in storage | ||
storage, // Storage mechanism (local storage or session storage) | ||
whitelist: ['course', 'student', 'instructor'], // Reducers to persist | ||
}; | ||
|
||
const persistedReducer = persistReducer(persistConfig, combineReducers({ | ||
auth: authReducer, | ||
course: courseReducer, | ||
student: studentReducer, | ||
instructor: instructorReducer, | ||
helper: helperReducer, | ||
})); | ||
|
||
const store = configureStore({ | ||
reducer: persistedReducer, // Use the persisted reducer | ||
}); | ||
|
||
const persistor = persistStore(store); | ||
|
||
export type State = typeof store; | ||
|
||
export type RootState = ReturnType<typeof store.getState>; | ||
|
||
export type AppDispatch = typeof store.dispatch; | ||
|
||
export {store,persistor} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters