From 7fe8de8ddf983a4d70f851443cc73d6a3f848989 Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Tue, 18 Jun 2024 16:35:01 +0530 Subject: [PATCH] [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 --- .../estimates/points/switch/root.tsx | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/web/ee/components/estimates/points/switch/root.tsx b/web/ee/components/estimates/points/switch/root.tsx index 2ef96ef500..0fec2682ca 100644 --- a/web/ee/components/estimates/points/switch/root.tsx +++ b/web/ee/components/estimates/points/switch/root.tsx @@ -84,28 +84,18 @@ export const EstimatePointSwitchRoot: FC = 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 = 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;