required issue fix

This commit is contained in:
Malini 2026-03-04 12:21:50 +05:30
parent f8ae83d88e
commit 094b9cd4f6

View File

@ -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}`]}