From 997c501d6a88a3780812149d988addc58b622e04 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 20 Dec 2023 15:46:10 -0500 Subject: [PATCH] fix(striker-ui): correct network count after remove in create manifest --- .../AnNetworkConfigInputGroup.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/striker-ui/components/ManageManifest/AnNetworkConfigInputGroup.tsx b/striker-ui/components/ManageManifest/AnNetworkConfigInputGroup.tsx index fd7f3004..b0db667f 100644 --- a/striker-ui/components/ManageManifest/AnNetworkConfigInputGroup.tsx +++ b/striker-ui/components/ManageManifest/AnNetworkConfigInputGroup.tsx @@ -267,24 +267,29 @@ const AnNetworkConfigInputGroup = < const handleNetworkRemove = useCallback( ({ networkId: rmId, networkType: rmType }) => { - let isIdMatch = false; + let postMatch = false; let networkNumber = 0; const newList = networkListEntries.reduce( (previous, [networkId, networkValue]) => { if (networkId === rmId) { - isIdMatch = true; - } else { - const { networkType } = networkValue; + postMatch = true; - if (networkType === rmType) { - networkNumber += 1; - } + return previous; + } - previous[networkId] = isIdMatch + const { networkType } = networkValue; + + const change = networkType === rmType; + + if (change) { + networkNumber += 1; + } + + previous[networkId] = + postMatch && change ? { ...networkValue, networkNumber } : networkValue; - } return previous; },