required issue fix
This commit is contained in:
parent
f8ae83d88e
commit
094b9cd4f6
@ -1654,8 +1654,8 @@ useEffect(() => {
|
|||||||
hasFieldErrors = true;
|
hasFieldErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Annual installed capacity is mandatory (0 should be valid)
|
// Annual installed capacity is mandatory (0 is not valid)
|
||||||
if (!product.capacity || product.capacity === '') {
|
if (!product.capacity || product.capacity === '' || product.capacity === '0') {
|
||||||
errors[`capacity_${index}`] = 'Capacity is required';
|
errors[`capacity_${index}`] = 'Capacity is required';
|
||||||
isValid = false;
|
isValid = false;
|
||||||
hasFieldErrors = true;
|
hasFieldErrors = true;
|
||||||
@ -2742,23 +2742,15 @@ useEffect(() => {
|
|||||||
displayValue={p.unitName || ''}
|
displayValue={p.unitName || ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const unitId = e.target.value;
|
const unitId = e.target.value;
|
||||||
const displayName = e.target.selectedDisplay ||
|
// console.log('Unit onChange debug:', {
|
||||||
unitOptions.find(u => u.value === unitId)?.label ||
|
// 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);
|
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}
|
loading={isLoadingUnits}
|
||||||
error={!!formErrors[`unit_${idx}`]}
|
error={!!formErrors[`unit_${idx}`]}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user