summaryrefslogtreecommitdiff
path: root/src/reducers/simulations.js
blob: 5a34ee7f7bac39cea2424b99b321f55d98bc0eed (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 {
    ADD_SIMULATION_SUCCEEDED,
    CLOSE_NEW_SIMULATION_MODAL,
    DELETE_SIMULATION,
    OPEN_NEW_SIMULATION_MODAL,
    SET_AUTH_VISIBILITY_FILTER
} from "../actions/simulations";
import {FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED} from "../actions/users";

export function authorizationsOfCurrentUser(state = [], action) {
    switch (action.type) {
        case FETCH_AUTHORIZATIONS_OF_CURRENT_USER_SUCCEEDED:
            return action.authorizationsOfCurrentUser;
        case ADD_SIMULATION_SUCCEEDED:
            return [
                ...state,
                action.authorization
            ];
        case DELETE_SIMULATION:
            return [];
        default:
            return state;
    }
}

export function newSimulationModalVisible(state = false, action) {
    switch (action.type) {
        case OPEN_NEW_SIMULATION_MODAL:
            return true;
        case CLOSE_NEW_SIMULATION_MODAL:
            return false;
        default:
            return state;
    }
}

export function authVisibilityFilter(state = "SHOW_ALL", action) {
    switch (action.type) {
        case SET_AUTH_VISIBILITY_FILTER:
            return action.filter;
        default:
            return state;
    }
}