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
+2 -9
View File
@@ -1,7 +1,5 @@
import { TUTORIAL_SUCCESS, TUTORIAL_ERROR, TUTORIAL_CHANGE } from './types';
import { tutorials } from '../components/Tutorial/tutorials';
export const tutorialChange = () => (dispatch) => {
dispatch({
type: TUTORIAL_CHANGE
@@ -9,16 +7,11 @@ export const tutorialChange = () => (dispatch) => {
};
export const tutorialCheck = (id, status) => (dispatch, getState) => {
var tutorialsStatus = getState().tutorial.status ?
getState().tutorial.status
: new Array(tutorials.length).fill({});
tutorialsStatus[id].status = status;
console.log(tutorials);
var tutorialsStatus = getState().tutorial.status;
tutorialsStatus[id] = {...tutorialsStatus[id], status: status};
dispatch({
type: status === 'success' ? TUTORIAL_SUCCESS : TUTORIAL_ERROR,
payload: tutorialsStatus
});
dispatch(tutorialChange());
// update locale storage - sync with redux store
window.localStorage.setItem('tutorial', JSON.stringify(tutorialsStatus));
};