diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-06 22:07:16 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:57 +0200 |
| commit | d5a92d3006561fd631279b68b23a1f8075b28bb8 (patch) | |
| tree | 39797ed1e314e5e3cd8521239141af1334f18ec5 /src/reducers/modals.js | |
| parent | 02eafd26b8841ed5896ab83672aba13d569ea63d (diff) | |
Add a button to delete the currently viewed room
Diffstat (limited to 'src/reducers/modals.js')
| -rw-r--r-- | src/reducers/modals.js | 54 |
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), }); |
