-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move QuizList state to store for persistency between page
- Loading branch information
Showing
6 changed files
with
119 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const TOGGLE_ACTIVE_QUIZZES = "TOGGLE_ACTIVE_QUIZZES"; | ||
export const UPDATE_SELECTED_TOPICS = "UPDATE_SELECTED_TOPICS"; | ||
export const UPDATE_SORTING = "UPDATE_SORTING"; | ||
|
||
export const toggleActiveQuizzes = () => ({ | ||
type: TOGGLE_ACTIVE_QUIZZES, | ||
}) | ||
|
||
export const updateSelectedTopics = (topics) => ({ | ||
type: UPDATE_SELECTED_TOPICS, | ||
payload: topics, | ||
}) | ||
|
||
export const updateSorting = (method) => ({ | ||
type: UPDATE_SORTING, | ||
payload: method | ||
}) |
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,11 +1,13 @@ | ||
import { combineReducers } from 'redux'; | ||
|
||
import { loginReducer } from './loginReducer'; | ||
import { toolReducer } from './toolReducer'; | ||
import { quizzReducer } from './quizzReducer'; | ||
import { postReducer } from './postReducer'; | ||
|
||
export default combineReducers({ | ||
loginReducer, | ||
toolReducer, | ||
quizzReducer, | ||
postReducer, | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
UPDATE_SELECTED_TOPICS, | ||
TOGGLE_ACTIVE_QUIZZES, | ||
UPDATE_SORTING | ||
} from "../actions"; | ||
|
||
const initialState = { | ||
activeOnly: false, | ||
selectedTopics: [], | ||
sortingMethod: "" | ||
}; | ||
|
||
export const toolReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case UPDATE_SELECTED_TOPICS: | ||
return { | ||
...state, | ||
selectedTopics: action.payload | ||
}; | ||
case TOGGLE_ACTIVE_QUIZZES: | ||
return { | ||
...state, | ||
activeOnly: !state.activeOnly | ||
}; | ||
case UPDATE_SORTING: | ||
return { | ||
...state, | ||
sortingMethod: action.payload | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; |