fix: converted and handled the estimate type to lowercase in the store (#5011)

This commit is contained in:
guru_sainath 2024-07-02 16:35:06 +05:30 committed by GitHub
parent d9d62c2d5a
commit 83587c2c6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,7 +5,7 @@ import update from "lodash/update";
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import { computedFn } from "mobx-utils";
// types
import { IEstimate as IEstimateType, IEstimateFormData } from "@plane/types";
import { IEstimate as IEstimateType, IEstimateFormData, TEstimateSystemKeys } from "@plane/types";
// plane web services
import estimateService from "@/plane-web/services/project/estimate.service";
// plane web store
@ -163,7 +163,12 @@ export class ProjectEstimateStore implements IProjectEstimateStore {
if (estimates && estimates.length > 0) {
runInAction(() => {
estimates.forEach((estimate) => {
if (estimate.id) set(this.estimates, [estimate.id], new Estimate(this.store, estimate));
if (estimate.id)
set(
this.estimates,
[estimate.id],
new Estimate(this.store, { ...estimate, type: estimate.type?.toLowerCase() as TEstimateSystemKeys })
);
});
});
}
@ -198,7 +203,12 @@ export class ProjectEstimateStore implements IProjectEstimateStore {
if (estimates && estimates.length > 0) {
runInAction(() => {
estimates.forEach((estimate) => {
if (estimate.id) set(this.estimates, [estimate.id], new Estimate(this.store, estimate));
if (estimate.id)
set(
this.estimates,
[estimate.id],
new Estimate(this.store, { ...estimate, type: estimate.type?.toLowerCase() as TEstimateSystemKeys })
);
});
});
}
@ -235,7 +245,11 @@ export class ProjectEstimateStore implements IProjectEstimateStore {
if (estimate.id)
update(this.estimates, [estimate.id], (estimateStore) => {
if (estimateStore) estimateStore.updateEstimate(estimate);
else return new Estimate(this.store, estimate);
else
return new Estimate(this.store, {
...estimate,
type: estimate.type?.toLowerCase() as TEstimateSystemKeys,
});
});
});
}
@ -272,7 +286,12 @@ export class ProjectEstimateStore implements IProjectEstimateStore {
// estimate: estimate.id,
// });
runInAction(() => {
if (estimate.id) set(this.estimates, [estimate.id], new Estimate(this.store, estimate));
if (estimate.id)
set(
this.estimates,
[estimate.id],
new Estimate(this.store, { ...estimate, type: estimate.type?.toLowerCase() as TEstimateSystemKeys })
);
});
}