[WEB-522] chore: updated input validation length in estimate point switch (#478)

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

* chore: updated input validation length in estimate point switch
This commit is contained in:
guru_sainath
2024-06-24 14:09:16 +05:30
committed by GitHub
parent eacd571728
commit f1dbaa80c4
2 changed files with 17 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ import { cn } from "@/helpers/common.helper";
// hooks
import { useEstimatePoint } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";
import { MAX_ESTIMATE_POINT_INPUT_LENGTH, EEstimateSystem } from "@/plane-web/constants/estimates";
type TEstimatePointItemSwitchPreview = {
estimateId: string;
@@ -31,6 +31,12 @@ export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview>
// hooks
const { asJson: estimatePoint } = useEstimatePoint(estimateId, estimatePointId);
const handleEstimatePointUpdate = (value: string) => {
if (value.length <= MAX_ESTIMATE_POINT_INPUT_LENGTH) {
handleEstimatePoint(value);
}
};
// derived values
const inputFieldType =
estimateSystemSwitchType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateSystemSwitchType)
@@ -39,7 +45,7 @@ export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview>
const inputProps = {
type: inputFieldType,
pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
maxlength: inputFieldType === "number" ? undefined : 24,
maxlength: MAX_ESTIMATE_POINT_INPUT_LENGTH,
};
if (!estimatePoint) return <></>;
@@ -59,7 +65,7 @@ export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview>
>
<input
value={currentEstimatePoint?.value}
onChange={(e) => handleEstimatePoint(e.target.value)}
onChange={(e) => handleEstimatePointUpdate(e.target.value)}
className="border-none focus:ring-0 focus:border-0 focus:outline-none p-2.5 w-full bg-transparent"
autoFocus
placeholder="Enter estimate point value"

View File

@@ -1,4 +1,10 @@
import { EEstimateSystem, EEstimateUpdateStages, estimateCount, ESTIMATE_SYSTEMS } from "ce/constants/estimates";
import {
MAX_ESTIMATE_POINT_INPUT_LENGTH,
EEstimateSystem,
EEstimateUpdateStages,
estimateCount,
ESTIMATE_SYSTEMS,
} from "ce/constants/estimates";
estimateCount.max = 12;
@@ -23,7 +29,7 @@ ESTIMATE_SYSTEMS.points.templates.squares.values = [
{ id: undefined, key: 9, value: "81" },
];
export { EEstimateSystem, EEstimateUpdateStages, estimateCount, ESTIMATE_SYSTEMS };
export { MAX_ESTIMATE_POINT_INPUT_LENGTH, EEstimateSystem, EEstimateUpdateStages, estimateCount, ESTIMATE_SYSTEMS };
export const ESTIMATE_OPTIONS_STAGE_ONE: Partial<
Record<EEstimateUpdateStages, { title: string; description: string }>