blob: 6381c8d94263b8181d6355bcb6cd94cf1cffd9ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import {combineReducers} from "redux";
import {ADD_TO_AUTHORIZATION_STORE, ADD_TO_SIMULATION_STORE, ADD_TO_USER_STORE} from "../actions/objects";
export const objects = combineReducers({
simulation,
authorization,
user,
});
function simulation(state = {}, action) {
switch (action.type) {
case ADD_TO_SIMULATION_STORE:
return Object.assign(
state,
{[action.simulation.id]: action.simulation}
);
default:
return state;
}
}
function authorization(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 user(state = {}, action) {
switch (action.type) {
case ADD_TO_USER_STORE:
return Object.assign(
state,
{[action.user.id]: action.user}
);
default:
return state;
}
}
|