diff --git a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
index c900cd1148..27e1cabd94 100644
--- a/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
+++ b/src/fireedge/src/client/containers/Provisions/DialogInfo/networks.js
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
-import { memo, useState } from 'react'
+import { memo, useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { Trash as DeleteIcon, AddCircledOutline } from 'iconoir-react'
@@ -37,9 +37,16 @@ const Networks = memo(({ id }) => {
const [amount, setAmount] = useState(() => 1)
const { enqueueSuccess } = useGeneralApi()
- const [addIp, { isLoading: loadingAddIp }] = useAddIpToProvisionMutation()
- const [removeResource, { isLoading: loadingRemove }] =
- useRemoveResourceMutation()
+ const [addIp, { isLoading: loadingAddIp, isSuccess: successAddIp }] =
+ useAddIpToProvisionMutation()
+ const [
+ removeResource,
+ {
+ isLoading: loadingRemove,
+ isSuccess: successRemove,
+ originalArgs: { id: vnetId } = {},
+ },
+ ] = useRemoveResourceMutation()
const { data = {} } = useGetProvisionQuery(id)
const provisionNetworks =
@@ -47,6 +54,14 @@ const Networks = memo(({ id }) => {
(network) => +network.id
) ?? []
+ useEffect(() => {
+ successAddIp && enqueueSuccess(`IP added ${amount}x`)
+ }, [successAddIp])
+
+ useEffect(() => {
+ successRemove && enqueueSuccess(`Network deleted - ID: ${vnetId}`)
+ }, [successRemove])
+
return (
<>
@@ -67,10 +82,7 @@ const Networks = memo(({ id }) => {
label={}
sx={{ ml: 1, display: 'flex', alignItems: 'flex-start' }}
isSubmitting={loadingAddIp}
- onClick={async () => {
- await addIp({ id, amount })
- enqueueSuccess(`IP added ${amount}x`)
- }}
+ onClick={async () => await addIp({ id, amount })}
/>
@@ -102,14 +114,13 @@ const Networks = memo(({ id }) => {
data-cy={`provision-vnet-delete-${vnet.ID}`}
icon={}
isSubmitting={loadingRemove}
- onClick={async () => {
- removeResource({
+ onClick={async () =>
+ await removeResource({
provision: id,
id: vnet.ID,
resource: 'network',
})
- enqueueSuccess(`Network deleted - ID: ${vnet.ID}`)
- }}
+ }
/>
>
}
diff --git a/src/fireedge/src/client/features/OneApi/provision.js b/src/fireedge/src/client/features/OneApi/provision.js
index cdf4909fee..7edfed8dc9 100644
--- a/src/fireedge/src/client/features/OneApi/provision.js
+++ b/src/fireedge/src/client/features/OneApi/provision.js
@@ -284,7 +284,7 @@ const provisionApi = oneApi.injectEndpoints({
* @throws Fails when response isn't code 200
*/
query: (params) => {
- const name = Actions.PROVISION_ADD_HOST
+ const name = Actions.PROVISION_ADD_IP
const command = { name, ...Commands[name] }
return { params, command }