Skip to content

Commit

Permalink
fix: estimate order not maintained in create/ update modal. (#3326)
Browse files Browse the repository at this point in the history
* fix: estimate order not maintained in create/ update modal.

* fix: estimate points mutation on update.
  • Loading branch information
prateekshourya29 authored Jan 8, 2024
1 parent 81f6557 commit a71491e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion web/components/estimates/estimates-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { EmptyState } from "components/common";
import emptyEstimate from "public/empty-state/estimate.svg";
// types
import { IEstimate } from "@plane/types";
// helpers
import { orderArrayBy } from "helpers/array.helper";

export const EstimatesList: React.FC = observer(() => {
// states
Expand All @@ -31,7 +33,11 @@ export const EstimatesList: React.FC = observer(() => {

const editEstimate = (estimate: IEstimate) => {
setEstimateFormOpen(true);
setEstimateToUpdate(estimate);
// Order the points array by key before updating the estimate to update state
setEstimateToUpdate({
...estimate,
points: orderArrayBy(estimate.points, "key"),
});
};

const disableEstimates = () => {
Expand Down
2 changes: 1 addition & 1 deletion web/store/estimate.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class EstimateStore implements IEstimateStore {
updateEstimate = async (workspaceSlug: string, projectId: string, estimateId: string, data: IEstimateFormData) =>
await this.estimateService.patchEstimate(workspaceSlug, projectId, estimateId, data).then((response) => {
const updatedEstimates = (this.estimates?.[projectId] ?? []).map((estimate) =>
estimate.id === estimateId ? { ...estimate, ...data.estimate } : estimate
estimate.id === estimateId ? { ...estimate, ...data.estimate, points: [...data.estimate_points] } : estimate
);
runInAction(() => {
set(this.estimates, projectId, updatedEstimates);
Expand Down

0 comments on commit a71491e

Please sign in to comment.