summaryrefslogtreecommitdiff
path: root/frontend/src/sagas/prefabs.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/sagas/prefabs.js')
-rw-r--r--frontend/src/sagas/prefabs.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/frontend/src/sagas/prefabs.js b/frontend/src/sagas/prefabs.js
new file mode 100644
index 00000000..94570404
--- /dev/null
+++ b/frontend/src/sagas/prefabs.js
@@ -0,0 +1,17 @@
+import {call, put, select} from "redux-saga/effects";
+import {addToStore} from "../actions/objects";
+import {addPrefab} from "../api/routes/prefabs";
+import {getTopologyAsObject} from "./objects";
+
+export function* onAddPrefab(action) {
+ try {
+ const currentRackId = yield select((state) => state.objects.tile[state.interactionLevel.tileId].rack._id)
+ const currentRackJson = yield call(getTopologyAsObject, currentRackId)
+ //TODO: yield call the function in saga to export the specific part of the topology
+ const prefab = yield call(addPrefab, { name: action.name, rack: currentRackJson })
+ yield put(addToStore('prefab', prefab))
+
+ } catch (error) {
+ console.error(error)
+ }
+}