chore: updated input validation on create and update estimate point form (#4900)

This commit is contained in:
guru_sainath 2024-06-21 13:27:56 +05:30 committed by GitHub
parent 7bb1f7c210
commit 69d67fc02a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -149,6 +149,15 @@ export const EstimatePointCreate: FC<TEstimatePointCreate> = observer((props) =>
} else handleEstimatePointError && handleEstimatePointError(estimateInputValue, "Estimate value cannot be empty.");
};
// derived values
const inputFieldType =
estimateType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateType) ? "number" : "text";
const inputProps = {
type: inputFieldType,
pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
maxlength: inputFieldType === "number" ? undefined : 24,
};
return (
<form onSubmit={handleCreate} className="relative flex items-center gap-2 text-base pr-2.5">
<div
@ -158,12 +167,12 @@ export const EstimatePointCreate: FC<TEstimatePointCreate> = observer((props) =>
)}
>
<input
type="text"
value={estimateInputValue}
onChange={(e) => handleEstimateInputValue(e.target.value)}
className="border-none focus:ring-0 focus:border-0 focus:outline-none p-2.5 w-full bg-transparent"
placeholder="Enter estimate point"
autoFocus
{...inputProps}
/>
{estimatePointError?.message && (
<Tooltip

View file

@ -157,6 +157,15 @@ export const EstimatePointUpdate: FC<TEstimatePointUpdate> = observer((props) =>
handleEstimatePointError && handleEstimatePointError(estimateInputValue || "", "Estimate value cannot be empty.");
};
// derived values
const inputFieldType =
estimateType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateType) ? "number" : "text";
const inputProps = {
type: inputFieldType,
pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
maxlength: inputFieldType === "number" ? undefined : 24,
};
return (
<form onSubmit={handleUpdate} className="relative flex items-center gap-2 text-base pr-2.5">
<div
@ -166,12 +175,12 @@ export const EstimatePointUpdate: FC<TEstimatePointUpdate> = observer((props) =>
)}
>
<input
type="text"
value={estimateInputValue}
onChange={(e) => handleEstimateInputValue(e.target.value)}
className="border-none focus:ring-0 focus:border-0 focus:outline-none p-2.5 w-full bg-transparent"
placeholder="Enter estimate point"
autoFocus
{...inputProps}
/>
{estimatePointError?.message && (
<>