brainlet-react/bfrontend/src/store.js

42 lines
972 B
JavaScript
Raw Normal View History

2020-12-29 22:55:53 +02:00
import { createStore } from 'redux';
const intitialState = {
user: null,
categories: null,
gateway: { isConnected: false }
};
const reducer = (state = intitialState, payload) => {
2020-12-29 22:55:53 +02:00
switch (payload.type) {
case 'authenticator/updatelocaluserobject': {
return {
...state,
user: payload.user
}
}
case 'categories/updatecategorylist': {
return {
...state,
categories: payload.categories
}
}
case 'gateway/connectionstatus': {
return {
...state,
gateway: {
isConnected: payload.gateway.isConnected
}
}
}
2020-12-29 22:55:53 +02:00
default: {
return state;
}
}
};
const store = createStore(reducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
export default store;