From 8eddc4b3047af0670180f29f3cdb616fbbf9315c Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Sun, 23 Apr 2023 00:00:46 +0530 Subject: [PATCH] fix: points not updating while editing estimate (#935) --- .../create-update-estimate-modal.tsx | 85 +++++++++++++------ apps/app/types/estimate.d.ts | 1 + 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/apps/app/components/estimates/create-update-estimate-modal.tsx b/apps/app/components/estimates/create-update-estimate-modal.tsx index 3d89e5fcf..98a5a430b 100644 --- a/apps/app/components/estimates/create-update-estimate-modal.tsx +++ b/apps/app/components/estimates/create-update-estimate-modal.tsx @@ -184,32 +184,65 @@ export const CreateUpdateEstimateModal: React.FC = ({ handleClose, data, name: formData.name, description: formData.description, }, - estimate_points: [ - { - key: 0, - value: formData.value1, - }, - { - key: 1, - value: formData.value2, - }, - { - key: 2, - value: formData.value3, - }, - { - key: 3, - value: formData.value4, - }, - { - key: 4, - value: formData.value5, - }, - { - key: 5, - value: formData.value6, - }, - ], + estimate_points: data + ? [ + { + id: data.points[0].id, + key: 0, + value: formData.value1, + }, + { + id: data.points[1].id, + key: 1, + value: formData.value2, + }, + { + id: data.points[2].id, + key: 2, + value: formData.value3, + }, + { + id: data.points[3].id, + key: 3, + value: formData.value4, + }, + { + id: data.points[4].id, + key: 4, + value: formData.value5, + }, + { + id: data.points[5].id, + key: 5, + value: formData.value6, + }, + ] + : [ + { + key: 0, + value: formData.value1, + }, + { + key: 1, + value: formData.value2, + }, + { + key: 2, + value: formData.value3, + }, + { + key: 3, + value: formData.value4, + }, + { + key: 4, + value: formData.value5, + }, + { + key: 5, + value: formData.value6, + }, + ], }; if (data) await updateEstimate(payload); diff --git a/apps/app/types/estimate.d.ts b/apps/app/types/estimate.d.ts index a222e1cf6..6d14a20ca 100644 --- a/apps/app/types/estimate.d.ts +++ b/apps/app/types/estimate.d.ts @@ -31,6 +31,7 @@ export interface IEstimateFormData { description: string; }; estimate_points: { + id?: string; key: number; value: string; }[];