2020-12-29 22:55:53 +02:00
|
|
|
import { createStore } from 'redux';
|
|
|
|
|
2021-01-08 00:53:42 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:40:03 +02:00
|
|
|
case 'categories/updatecategorylist': {
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
categories: payload.categories
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 00:53:42 +02:00
|
|
|
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;
|