[WEB-1672] chore: updated input validation on switch estimate point form and truncated in issues (#459)

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

* chore: updated input validation on switche estimate point form

---------

Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
This commit is contained in:
guru_sainath
2024-06-21 15:14:44 +05:30
committed by GitHub
parent 1de6728b18
commit 70dac1dd8b
2 changed files with 19 additions and 3 deletions

View File

@@ -1,15 +1,18 @@
import { FC } from "react";
import { observer } from "mobx-react";
import { Info, MoveRight } from "lucide-react";
import { TEstimatePointsObject, TEstimateTypeErrorObject } from "@plane/types";
import { TEstimatePointsObject, TEstimateSystemKeys, TEstimateTypeErrorObject } from "@plane/types";
import { Tooltip } from "@plane/ui";
// helpers
import { cn } from "@/helpers/common.helper";
// hooks
import { useEstimatePoint } from "@/hooks/store";
// plane web constants
import { EEstimateSystem } from "@/plane-web/constants/estimates";
type TEstimatePointItemSwitchPreview = {
estimateId: string;
estimateSystemSwitchType: TEstimateSystemKeys;
estimatePointId: string | undefined;
estimatePoint: TEstimatePointsObject;
handleEstimatePoint: (value: string) => void;
@@ -19,6 +22,7 @@ type TEstimatePointItemSwitchPreview = {
export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview> = observer((props) => {
const {
estimateId,
estimateSystemSwitchType,
estimatePointId,
estimatePoint: currentEstimatePoint,
handleEstimatePoint,
@@ -27,6 +31,17 @@ export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview>
// hooks
const { asJson: estimatePoint } = useEstimatePoint(estimateId, estimatePointId);
// derived values
const inputFieldType =
estimateSystemSwitchType && [(EEstimateSystem.TIME, EEstimateSystem.POINTS)].includes(estimateSystemSwitchType)
? "number"
: "text";
const inputProps = {
type: inputFieldType,
pattern: inputFieldType === "number" ? "[0-9]*" : undefined,
maxlength: inputFieldType === "number" ? undefined : 24,
};
if (!estimatePoint) return <></>;
return (
<div className="relative flex items-center gap-2">
@@ -43,12 +58,12 @@ export const EstimatePointItemSwitchPreview: FC<TEstimatePointItemSwitchPreview>
)}
>
<input
type="text"
value={currentEstimatePoint?.value}
onChange={(e) => handleEstimatePoint(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"
{...inputProps}
/>
{estimatePointError?.message && (
<>

View File

@@ -186,7 +186,7 @@ export const EstimatePointSwitchRoot: FC<TEstimatePointSwitchRoot> = observer((p
>
<ChevronLeft className="w-4 h-4" />
</div>
<div className="text-xl font-medium text-custom-text-200">Edit estimate system</div>
<div className="text-xl font-medium text-custom-text-200">Switch estimate system</div>
</div>
</div>
@@ -202,6 +202,7 @@ export const EstimatePointSwitchRoot: FC<TEstimatePointSwitchRoot> = observer((p
key={estimateObject?.id}
estimateId={estimateId}
estimatePointId={estimateObject?.id}
estimateSystemSwitchType={estimateSystemSwitchType}
estimatePoint={estimateObject}
handleEstimatePoint={(value: string) => handleEstimatePoints(index, value)}
estimatePointError={estimatePointError?.[estimateObject.key] || undefined}