required issue fix
This commit is contained in:
parent
09bfad5cd0
commit
f8ae83d88e
@ -1899,6 +1899,15 @@ useEffect(() => {
|
||||
if (newErrors[errorKey] && value && value !== '') {
|
||||
delete newErrors[errorKey];
|
||||
setFormErrors(newErrors);
|
||||
|
||||
// Force update with a new object reference
|
||||
setTimeout(() => {
|
||||
const freshErrors = { ...formErrors };
|
||||
if (freshErrors[errorKey]) {
|
||||
delete freshErrors[errorKey];
|
||||
setFormErrors(freshErrors);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// Format value for cost fields to treat last two digits as decimals
|
||||
@ -2737,16 +2746,19 @@ useEffect(() => {
|
||||
unitOptions.find(u => u.value === unitId)?.label ||
|
||||
'';
|
||||
|
||||
// Update both unit and unitName in a single update
|
||||
const updatedProduct = {
|
||||
...p,
|
||||
unit: unitId,
|
||||
unitName: displayName
|
||||
};
|
||||
// Use updateProductField to handle error clearing
|
||||
updateProductField(p.id, 'unit', unitId, unitOptions);
|
||||
|
||||
// Also update unitName separately
|
||||
const updatedProducts = [...products];
|
||||
updatedProducts[idx] = updatedProduct;
|
||||
onProductsChange(updatedProducts);
|
||||
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}`]}
|
||||
@ -2949,6 +2961,7 @@ useEffect(() => {
|
||||
className="w-24"
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
required
|
||||
value={p.janCost || ''}
|
||||
error={!!formErrors[`janCost_${idx}`]}
|
||||
placeholder="Enter"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user