Skip to content

Commit

Permalink
chore: remove useEffect as modals are closed using mutate handlers
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <gulsum.atici@canonical.com>
  • Loading branch information
gatici committed Jan 9, 2025
1 parent d3c3f4c commit baca60e
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions app/(nms)/network-configuration/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
import {
Button,
Card,
Expand All @@ -24,7 +24,6 @@ const NetworkConfiguration = () => {
const [isCreateModalVisible, setCreateModalVisible] = useState(false);
const [isEditModalVisible, setEditModalVisible] = useState(false);
const [networkSlice, setNetworkSlice] = useState<NetworkSlice | undefined>(undefined);
const [refresh, setRefresh] = useState(false);
const auth = useAuth()

const { data: networkSlices = [], isLoading: loading, status: networkSlicesQueryStatus, error: networkSlicesQueryError } = useQuery({
Expand Down Expand Up @@ -52,18 +51,6 @@ const NetworkConfiguration = () => {
},
});

// Trigger UI refresh when refresh flag is set
useEffect(() => {
if (refresh) {
// Reset refresh state
setRefresh(false);
// Close modal after adding network slice
setCreateModalVisible(false);
// Close modal after editing network slice
setEditModalVisible(false);
}
}, [refresh, setCreateModalVisible, setEditModalVisible]);

const handleAddNetworkSlice = (newSlice: NetworkSlice) => {
addNetworkSliceMutation.mutate(newSlice, {
onSuccess: () => {
Expand Down Expand Up @@ -153,7 +140,7 @@ const NetworkConfiguration = () => {
confirmationModalProps={{
title: "Warning",
confirmButtonLabel: "Delete",
buttonRow: (null),
buttonRow: null,
onConfirm: () => { },
children: (
<p>
Expand Down

0 comments on commit baca60e

Please sign in to comment.