summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js')
-rw-r--r--opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
index 55f8bd00..78db166c 100644
--- a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
+++ b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
@@ -3,28 +3,32 @@ import { useDispatch } from 'react-redux'
import TopologyListComponent from '../../../../components/app/sidebars/project/TopologyListComponent'
import { setCurrentTopology } from '../../../../redux/actions/topology/building'
import { useRouter } from 'next/router'
-import { addTopology, deleteTopology } from '../../../../redux/actions/topologies'
+import { addTopology } from '../../../../redux/actions/topologies'
import NewTopologyModalComponent from '../../../../components/modals/custom-components/NewTopologyModalComponent'
-import { useActiveTopology, useProjectTopologies } from '../../../../data/topology'
+import { useActiveTopology, useTopologies } from '../../../../data/topology'
import { useProject } from '../../../../data/project'
+import { useMutation } from 'react-query'
const TopologyListContainer = () => {
const dispatch = useDispatch()
const router = useRouter()
const { project: currentProjectId } = router.query
const { data: currentProject } = useProject(currentProjectId)
- const topologies = useProjectTopologies()
+ const topologies = useTopologies(currentProject?.topologyIds ?? [])
+ .filter((res) => res.data)
+ .map((res) => res.data)
const currentTopologyId = useActiveTopology()?._id
const [isVisible, setVisible] = useState(false)
+ const { mutate: deleteTopology } = useMutation('deleteTopology')
+
const onChooseTopology = async (id) => {
dispatch(setCurrentTopology(id))
await router.push(`/projects/${currentProjectId}/topologies/${id}`)
}
const onDeleteTopology = async (id) => {
if (id) {
- dispatch(deleteTopology(id))
- dispatch(setCurrentTopology(currentProject.topologyIds[0]))
+ deleteTopology(id)
await router.push(`/projects/${currentProjectId}`)
}
}