From 91c8088e1d7def9242f60c708cd34f25dcb77d76 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 15 Aug 2017 23:24:28 +0300 Subject: Connect to backend and fetch initial project data --- src/reducers/objects.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/reducers/objects.js (limited to 'src/reducers/objects.js') 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; + } +} -- cgit v1.2.3