From 07195f3762b6a8a7dfb44c2231db58c5be13c43f Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 16 Aug 2017 22:55:16 +0300 Subject: Rename project to sim and enable sim-adding --- src/reducers/simulations.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/reducers/simulations.js (limited to 'src/reducers/simulations.js') diff --git a/src/reducers/simulations.js b/src/reducers/simulations.js new file mode 100644 index 00000000..5a34ee7f --- /dev/null +++ b/src/reducers/simulations.js @@ -0,0 +1,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; + } +} -- cgit v1.2.3