fixed status update of tutorials

This commit is contained in:
Delucse
2020-09-08 11:55:08 +02:00
parent e322795f25
commit de0bfd5d49
2 changed files with 8 additions and 10 deletions
+6 -1
View File
@@ -1,8 +1,11 @@
import { TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE } from '../actions/types';
import { tutorials } from '../components/Tutorial/tutorials';
const initialState = {
status: JSON.parse(window.localStorage.getItem('tutorial')),
status: window.localStorage.getItem('tutorial') ?
JSON.parse(window.localStorage.getItem('tutorial'))
: new Array(tutorials.length).fill({}),
change: 0
};
@@ -10,6 +13,8 @@ export default function(state = initialState, action){
switch(action.type){
case TUTORIAL_SUCCESS:
case TUTORIAL_ERROR:
// update locale storage - sync with redux store
window.localStorage.setItem('tutorial', JSON.stringify(action.payload));
return {
...state,
status: action.payload