diff --git a/web/ee/components/estimates/points/switch/preview.tsx b/web/ee/components/estimates/points/switch/preview.tsx index 8e993506c6..1830ed36b2 100644 --- a/web/ee/components/estimates/points/switch/preview.tsx +++ b/web/ee/components/estimates/points/switch/preview.tsx @@ -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 = observer((props) => { const { estimateId, + estimateSystemSwitchType, estimatePointId, estimatePoint: currentEstimatePoint, handleEstimatePoint, @@ -27,6 +31,17 @@ export const EstimatePointItemSwitchPreview: FC // 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 (
@@ -43,12 +58,12 @@ export const EstimatePointItemSwitchPreview: FC )} > 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 && ( <> diff --git a/web/ee/components/estimates/points/switch/root.tsx b/web/ee/components/estimates/points/switch/root.tsx index 0fec2682ca..f88640e841 100644 --- a/web/ee/components/estimates/points/switch/root.tsx +++ b/web/ee/components/estimates/points/switch/root.tsx @@ -186,7 +186,7 @@ export const EstimatePointSwitchRoot: FC = observer((p >
-
Edit estimate system
+
Switch estimate system
@@ -202,6 +202,7 @@ export const EstimatePointSwitchRoot: FC = 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}