chore: updated input validation on create and update estimate point form (#4900)
This commit is contained in:
parent
7bb1f7c210
commit
69d67fc02a
2 changed files with 20 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 && (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue