From 3a5dd5ca3bfc7aa67e84b945392de1c027a142a8 Mon Sep 17 00:00:00 2001 From: Malini Date: Fri, 20 Feb 2026 10:25:50 +0530 Subject: [PATCH] fix product issue --- .../Admin/configuration/EditCompanyProfile.jsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx b/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx index 6c0c295..c0c9b34 100644 --- a/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx +++ b/ipi-survey-platform/src/pages/Admin/configuration/EditCompanyProfile.jsx @@ -329,8 +329,6 @@ const EditCompanyProfile = () => { (p.product_id && p.product_id === productValue) ); - - if (newChecked.has(productValue)) { // Unchecking: move product from selected to available newChecked.delete(productValue); @@ -345,17 +343,15 @@ const EditCompanyProfile = () => { ); if (!alreadyExists) { - ('ADDING TO AVAILABLE - new length will be:', prev.length + 1); + console.log('ADDING TO AVAILABLE - new length will be:', prev.length + 1); return [...prev, product]; } return prev; }); } } else { - // Re-checking: remove newly added products and restore original - if (newChecked.size < selectedProducts.length) { - newChecked.add(productValue); - } + // Re-checking: add the product back to checked + newChecked.add(productValue); // Remove from available products setAvailableProducts(prev => @@ -391,8 +387,8 @@ const EditCompanyProfile = () => { const productsToAdd = newlyAddedProducts.filter(np => !prev.some(p => (p.value && (p.value === np.value || p.value === np.id || p.value === np.product_id)) || - (p.id && (p.id === np.id || p.id === np.value || np.id === np.product_id)) || - (p.product_id && (p.product_id === np.product_id || np.product_id === np.id || np.product_id === np.value)) + (p.id && (p.id === np.id || p.id === np.value || p.id === np.product_id)) || + (p.product_id && (p.product_id === np.product_id || p.product_id === np.id || p.product_id === np.value)) ) ); return [...prev, ...productsToAdd]; @@ -401,7 +397,7 @@ const EditCompanyProfile = () => { // Clear newly added product IDs setNewlyAddedProductIds(new Set()); - // Refresh component to update the UI while staying on current step + // Refresh component to update UI while staying on current step navigate(window.location.pathname); } }