diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-15 23:24:28 +0300 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:42 +0200 |
| commit | 91c8088e1d7def9242f60c708cd34f25dcb77d76 (patch) | |
| tree | b68065019692cea5cf6c3d14b811104aff2f0879 /src/reducers/objects.js | |
| parent | d7512ace72448242b392299cf459c9c72c8dbee5 (diff) | |
Connect to backend and fetch initial project data
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; + } +} |
