current tutorial id stored in redux store
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE } from '../actions/types';
|
||||
import { TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE, TUTORIAL_XML, TUTORIAL_ID } from '../actions/types';
|
||||
|
||||
import { tutorials } from '../components/Tutorial/tutorials';
|
||||
|
||||
@@ -6,6 +6,7 @@ const initialState = {
|
||||
status: window.localStorage.getItem('tutorial') ?
|
||||
JSON.parse(window.localStorage.getItem('tutorial'))
|
||||
: new Array(tutorials.length).fill({}),
|
||||
currentId: null,
|
||||
change: 0
|
||||
};
|
||||
|
||||
@@ -13,6 +14,7 @@ export default function(state = initialState, action){
|
||||
switch(action.type){
|
||||
case TUTORIAL_SUCCESS:
|
||||
case TUTORIAL_ERROR:
|
||||
case TUTORIAL_XML:
|
||||
// update locale storage - sync with redux store
|
||||
window.localStorage.setItem('tutorial', JSON.stringify(action.payload));
|
||||
return {
|
||||
@@ -24,6 +26,11 @@ export default function(state = initialState, action){
|
||||
...state,
|
||||
change: state.change += 1
|
||||
}
|
||||
case TUTORIAL_ID:
|
||||
return {
|
||||
...state,
|
||||
currentId: action.payload
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user