fix: estimate order not maintained in create/ update modal. (#3326)

* fix: estimate order not maintained in create/ update modal.

* fix: estimate points mutation on update.
This commit is contained in:
Prateek Shourya 2024-01-08 16:16:45 +05:30 committed by sriram veeraghanta
parent b62a1b11b1
commit 12a3392722
2 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,8 @@ import { EmptyState } from "components/common";
import emptyEstimate from "public/empty-state/estimate.svg"; import emptyEstimate from "public/empty-state/estimate.svg";
// types // types
import { IEstimate } from "@plane/types"; import { IEstimate } from "@plane/types";
// helpers
import { orderArrayBy } from "helpers/array.helper";
export const EstimatesList: React.FC = observer(() => { export const EstimatesList: React.FC = observer(() => {
// states // states
@ -31,7 +33,11 @@ export const EstimatesList: React.FC = observer(() => {
const editEstimate = (estimate: IEstimate) => { const editEstimate = (estimate: IEstimate) => {
setEstimateFormOpen(true); 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 = () => { const disableEstimates = () => {

View File

@ -172,7 +172,7 @@ export class EstimateStore implements IEstimateStore {
updateEstimate = async (workspaceSlug: string, projectId: string, estimateId: string, data: IEstimateFormData) => updateEstimate = async (workspaceSlug: string, projectId: string, estimateId: string, data: IEstimateFormData) =>
await this.estimateService.patchEstimate(workspaceSlug, projectId, estimateId, data).then((response) => { await this.estimateService.patchEstimate(workspaceSlug, projectId, estimateId, data).then((response) => {
const updatedEstimates = (this.estimates?.[projectId] ?? []).map((estimate) => 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(() => { runInAction(() => {
set(this.estimates, projectId, updatedEstimates); set(this.estimates, projectId, updatedEstimates);