summaryrefslogtreecommitdiff
path: root/src/reducers/modals.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/reducers/modals.js')
-rw-r--r--src/reducers/modals.js54
1 files changed, 20 insertions, 34 deletions
diff --git a/src/reducers/modals.js b/src/reducers/modals.js
index 1786bb87..f6d1efea 100644
--- a/src/reducers/modals.js
+++ b/src/reducers/modals.js
@@ -1,43 +1,29 @@
import {combineReducers} from "redux";
import {CLOSE_DELETE_PROFILE_MODAL, OPEN_DELETE_PROFILE_MODAL} from "../actions/modals/profile";
import {CLOSE_NEW_SIMULATION_MODAL, OPEN_NEW_SIMULATION_MODAL} from "../actions/modals/simulations";
-import {CLOSE_EDIT_ROOM_NAME_MODAL, OPEN_EDIT_ROOM_NAME_MODAL} from "../actions/modals/topology";
+import {
+ CLOSE_DELETE_ROOM_MODAL,
+ CLOSE_EDIT_ROOM_NAME_MODAL,
+ OPEN_DELETE_ROOM_MODAL,
+ OPEN_EDIT_ROOM_NAME_MODAL
+} from "../actions/modals/topology";
-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;
- }
-}
-
-function deleteProfileModalVisible(state = false, action) {
- switch (action.type) {
- case OPEN_DELETE_PROFILE_MODAL:
- return true;
- case CLOSE_DELETE_PROFILE_MODAL:
- return false;
- default:
- return state;
- }
-}
-
-function editRoomNameModalVisible(state = false, action) {
- switch (action.type) {
- case OPEN_EDIT_ROOM_NAME_MODAL:
- return true;
- case CLOSE_EDIT_ROOM_NAME_MODAL:
- return false;
- default:
- return state;
+function modal(openAction, closeAction) {
+ return function (state = false, action) {
+ switch (action.type) {
+ case openAction:
+ return true;
+ case closeAction:
+ return false;
+ default:
+ return state;
+ }
}
}
export const modals = combineReducers({
- newSimulationModalVisible,
- deleteProfileModalVisible,
- editRoomNameModalVisible,
+ newSimulationModalVisible: modal(OPEN_NEW_SIMULATION_MODAL, CLOSE_NEW_SIMULATION_MODAL),
+ deleteProfileModalVisible: modal(OPEN_DELETE_PROFILE_MODAL, CLOSE_DELETE_PROFILE_MODAL),
+ editRoomNameModalVisible: modal(OPEN_EDIT_ROOM_NAME_MODAL, CLOSE_EDIT_ROOM_NAME_MODAL),
+ deleteRoomModalVisible: modal(OPEN_DELETE_ROOM_MODAL, CLOSE_DELETE_ROOM_MODAL),
});