From 094b9cd4f68cf5c9675a0cdf4ef446e5af03f0f4 Mon Sep 17 00:00:00 2001 From: Malini Date: Wed, 4 Mar 2026 12:21:50 +0530 Subject: [PATCH] required issue fix --- .../survey/ProductData/ProductData.jsx | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx index 7e474f0..7746306 100644 --- a/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx +++ b/ipi-survey-platform/src/components/survey/ProductData/ProductData.jsx @@ -1654,8 +1654,8 @@ useEffect(() => { hasFieldErrors = true; } - // Annual installed capacity is mandatory (0 should be valid) - if (!product.capacity || product.capacity === '') { + // Annual installed capacity is mandatory (0 is not valid) + if (!product.capacity || product.capacity === '' || product.capacity === '0') { errors[`capacity_${index}`] = 'Capacity is required'; isValid = false; hasFieldErrors = true; @@ -2742,23 +2742,15 @@ useEffect(() => { displayValue={p.unitName || ''} onChange={(e) => { const unitId = e.target.value; - const displayName = e.target.selectedDisplay || - unitOptions.find(u => u.value === unitId)?.label || - ''; + // console.log('Unit onChange debug:', { + // productId: p.id, + // unitId, + // unitIdType: typeof unitId, + // unitIdIsEmpty: unitId === '' + // }); - // Use updateProductField to handle error clearing + // Use updateProductField to handle both unit and unitName updates updateProductField(p.id, 'unit', unitId, unitOptions); - - // Also update unitName separately - const updatedProducts = [...products]; - const productIndex = updatedProducts.findIndex(prod => prod.id === p.id); - if (productIndex !== -1) { - updatedProducts[productIndex] = { - ...updatedProducts[productIndex], - unitName: displayName - }; - onProductsChange(updatedProducts); - } }} loading={isLoadingUnits} error={!!formErrors[`unit_${idx}`]}