diff options
Diffstat (limited to 'src/reducers/objects.js')
| -rw-r--r-- | src/reducers/objects.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/reducers/objects.js b/src/reducers/objects.js new file mode 100644 index 00000000..69e68ca7 --- /dev/null +++ b/src/reducers/objects.js @@ -0,0 +1,44 @@ +import {combineReducers} from "redux"; +import {ADD_TO_AUTHORIZATION_STORE, ADD_TO_SIMULATION_STORE, ADD_TO_USER_STORE} from "../actions/object-stores"; + +export const objects = combineReducers({ + simulations, + authorizations, + users, +}); + +function simulations(state = {}, action) { + switch (action.type) { + case ADD_TO_SIMULATION_STORE: + return Object.assign( + state, + {[action.simulation.id]: action.simulation} + ); + default: + return state; + } +} + +function authorizations(state = {}, action) { + switch (action.type) { + case ADD_TO_AUTHORIZATION_STORE: + return Object.assign( + state, + {[[action.authorization.userId, action.authorization.simulationId]]: action.authorization} + ); + default: + return state; + } +} + +function users(state = {}, action) { + switch (action.type) { + case ADD_TO_USER_STORE: + return Object.assign( + state, + {[action.user.id]: action.user} + ); + default: + return state; + } +} |
