summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-03-07 18:19:21 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2022-04-04 12:48:05 +0200
commit3d1c02e50ee619598bcd7fad4368be8b4a039e84 (patch)
tree89baaf3250eb0495295616a9945c681f5e1ccdb8 /opendc-web/opendc-web-ui/src/components/projects/NewTopology.js
parentd12efc754a1611a624d170b4d1fa6085e6bb177b (diff)
refactor(web/ui): Fix compatibility with new API
This change updates the web interface in React to be compatible with the new API written in Kotlin. Several changes have been made in the new API to ensure consistency.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components/projects/NewTopology.js')
-rw-r--r--opendc-web/opendc-web-ui/src/components/projects/NewTopology.js16
1 files changed, 4 insertions, 12 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js b/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js
index 77c57d26..4c569c56 100644
--- a/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js
+++ b/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js
@@ -21,25 +21,17 @@
*/
import PropTypes from 'prop-types'
-import produce from 'immer'
import { PlusIcon } from '@patternfly/react-icons'
import { Button } from '@patternfly/react-core'
import { useState } from 'react'
-import { useMutation } from "react-query";
-import { useProjectTopologies } from "../../data/topology";
+import { useNewTopology } from '../../data/topology'
import NewTopologyModal from './NewTopologyModal'
function NewTopology({ projectId }) {
const [isVisible, setVisible] = useState(false)
- const { data: topologies = [] } = useProjectTopologies(projectId)
- const { mutate: addTopology } = useMutation('addTopology')
+ const { mutate: addTopology } = useNewTopology()
- const onSubmit = (name, duplicateId) => {
- const candidate = topologies.find((topology) => topology._id === duplicateId) || { projectId, rooms: [] }
- const topology = produce(candidate, (draft) => {
- delete draft._id
- draft.name = name
- })
+ const onSubmit = (topology) => {
addTopology(topology)
setVisible(false)
}
@@ -59,7 +51,7 @@ function NewTopology({ projectId }) {
}
NewTopology.propTypes = {
- projectId: PropTypes.string,
+ projectId: PropTypes.number,
}
export default NewTopology