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