[WEB-1637] fix: validating estimate points in switch and making the switch request once every validation is successful (#434)

* fix: validating and showing proper alert estimate point has to be taken greater than 0 in create and update

* fix: validating estimate points in switch and making the switch request once every validation is successfull
This commit is contained in:
guru_sainath
2024-06-18 16:35:01 +05:30
committed by GitHub
parent c11e547fde
commit 7fe8de8ddf

View File

@@ -84,28 +84,18 @@ export const EstimatePointSwitchRoot: FC<TEstimatePointSwitchRoot> = observer((p
handleEstimatePointError(estimatePoint.key, "", "", "Please fill this estimate point field");
}
});
if (isNonEmptyPoints.length === estimatePoints?.length) {
isValid = true;
} else {
isValid = false;
}
// validate if fields are repeated
const repeatedValues: string[] = [];
estimatePoints?.map((estimatePoint) => {
if (estimatePoint.value && estimatePoint.value != "") {
if (repeatedValues.includes(estimatePoint.value)) {
if (repeatedValues.includes(estimatePoint.value.trim())) {
handleEstimatePointError(estimatePoint.key, "", "", "Estimate point value cannot be repeated");
} else {
repeatedValues.push(estimatePoint.value);
repeatedValues.push(estimatePoint.value.trim());
}
}
});
if (repeatedValues.length === estimatePoints?.length) {
isValid = true;
} else {
isValid = false;
}
// validate if fields are valid in points and time required number values and categories required string values
const estimatePointArray: string[] = [];
@@ -134,7 +124,12 @@ export const EstimatePointSwitchRoot: FC<TEstimatePointSwitchRoot> = observer((p
}
});
}
if (estimatePointArray.length === estimatePoints?.length) {
if (
isNonEmptyPoints.length === estimatePoints?.length &&
repeatedValues.length === estimatePoints?.length &&
estimatePointArray.length === estimatePoints?.length
) {
isValid = true;
} else {
isValid = false;