diff --git a/web/components/estimates/update/modal.tsx b/web/components/estimates/update/modal.tsx index ce0c9bf1c..1cc59884b 100644 --- a/web/components/estimates/update/modal.tsx +++ b/web/components/estimates/update/modal.tsx @@ -56,14 +56,19 @@ export const UpdateEstimateModal: FC = observer((props) => // derived values const renderEstimateStepsCount = useMemo(() => (estimatePoints ? "2" : "1"), [estimatePoints]); + const isNewEstimatePointsToCreate = + (estimatePoints || []).filter((point) => point.id === undefined).length > 0 ? true : false; - const handleCreateEstimate = async () => { + const handleUpdateEstimate = async () => { try { if (!workspaceSlug || !projectId || !estimateId || currentEstimate?.type === undefined) return; + + const currentEstimatePoints = (estimatePoints || []).filter((point) => point.id === undefined); const currentEstimationType: TEstimateSystemKeys = currentEstimate?.type; const validatedEstimatePoints: TEstimatePointsObject[] = []; + if ([EEstimateSystem.POINTS, EEstimateSystem.TIME].includes(currentEstimationType)) { - estimatePoints?.map((estimatePoint) => { + currentEstimatePoints?.map((estimatePoint) => { if ( estimatePoint.value && ((estimatePoint.value != "0" && Number(estimatePoint.value)) || estimatePoint.value === "0") @@ -71,15 +76,13 @@ export const UpdateEstimateModal: FC = observer((props) => validatedEstimatePoints.push(estimatePoint); }); } else { - estimatePoints?.map((estimatePoint) => { + currentEstimatePoints?.map((estimatePoint) => { if (estimatePoint.value) validatedEstimatePoints.push(estimatePoint); }); } - if (validatedEstimatePoints.length === estimatePoints?.length) { + + if (validatedEstimatePoints.length === currentEstimatePoints?.length) { const payload: IEstimateFormData = { - estimate: { - type: "points", - }, estimate_points: validatedEstimatePoints, }; await updateEstimate(payload); @@ -144,9 +147,9 @@ export const UpdateEstimateModal: FC = observer((props) => - {estimatePoints && ( - )} diff --git a/web/components/estimates/update/stage-two.tsx b/web/components/estimates/update/stage-two.tsx index 4d6f61ebe..2ecae1000 100644 --- a/web/components/estimates/update/stage-two.tsx +++ b/web/components/estimates/update/stage-two.tsx @@ -1,4 +1,5 @@ import { FC } from "react"; +import { observer } from "mobx-react"; import { Plus } from "lucide-react"; import { IEstimate, TEstimatePointsObject, TEstimateUpdateStageKeys } from "@plane/types"; import { Button, Sortable } from "@plane/ui"; @@ -14,7 +15,7 @@ type TEstimateUpdateStageTwo = { handleEstimatePoints: (value: TEstimatePointsObject[]) => void; }; -export const EstimateUpdateStageTwo: FC = (props) => { +export const EstimateUpdateStageTwo: FC = observer((props) => { const { estimate, estimateEditType, estimatePoints, handleEstimatePoints } = props; const currentEstimateSystem = estimate || undefined; @@ -85,4 +86,4 @@ export const EstimateUpdateStageTwo: FC = (props) => { ); -}; +}); diff --git a/web/store/estimates/estimate.ts b/web/store/estimates/estimate.ts index fb0084ff8..86b09f39f 100644 --- a/web/store/estimates/estimate.ts +++ b/web/store/estimates/estimate.ts @@ -148,7 +148,7 @@ export class Estimate implements IEstimate { const { workspaceSlug, projectId } = this.store.router; if (!workspaceSlug || !projectId || !this.id || !payload) return; - // make update estimation request + await this.service.updateEstimate(workspaceSlug, projectId, this.id, payload); // runInAction(() => { // this.points = payload.estimate_points;