summaryrefslogtreecommitdiff
path: root/src/reducers/simulations.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-08-16 22:55:16 +0300
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-23 10:05:42 +0200
commit07195f3762b6a8a7dfb44c2231db58c5be13c43f (patch)
tree2b4640457f70b55a97aff22fbe617e4b8538464a /src/reducers/simulations.js
parent91c8088e1d7def9242f60c708cd34f25dcb77d76 (diff)
Rename project to sim and enable sim-adding
Diffstat (limited to 'src/reducers/simulations.js')
-rw-r--r--src/reducers/simulations.js44
1 files changed, 44 insertions, 0 deletions
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;
+ }
+}