Continue move to redux

This commit is contained in:
Scott E. Graves
2019-06-05 23:46:30 -05:00
parent 6056e2d063
commit a1a144b1d2
8 changed files with 157 additions and 61 deletions

View File

@@ -0,0 +1,53 @@
import {createReducer} from 'redux-starter-kit';
import * as Actions from '../actions/release_version_actions';
import * as Constants from '../../constants';
const versionLookup = Constants.RELEASE_TYPES.map(k=> {
return {
[k]: ['unavailable']
};
}).reduce((map, obj) => {
return {
...map,
...obj,
};
});
export const releaseVersionReducer = createReducer({
LocationsLookup: {},
Release: 2,
UpgradeAvailable: false,
UpgradeDismissed: false,
Version: -1,
VersionLookup: versionLookup,
}, {
[Actions.CLEAR_UI_UPGRADE]: state => {
return {
...state,
UpgradeAvailable: false,
UpgradeDismissed: false,
UpgradeData: null,
};
},
[Actions.SET_ACTIVE_RELEASE]: (state, action) => {
return {
...state,
Release: action.payload.release,
Version: action.payload.version
};
},
[Actions.setDismissUIUpgrade]: (state, action) => {
return {
...state,
UpgradeDismissed: action.payload,
};
},
[Actions.setUIUpgradeData]: (state, action) => {
return {
...state,
UpgradeAvailable: true,
UpgradeData: action.payload,
UpgradeDismissed: false,
};
}
});