From 96f6e37cc550dbac8b9dbcc152562acdd5f6973e Mon Sep 17 00:00:00 2001 From: sabith-tu <95301637+sabith-tu@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:08:52 +0530 Subject: [PATCH] fix: Delete estimate popup is not closing automatically (#2777) --- .../estimates/delete-estimate-modal.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/web/components/estimates/delete-estimate-modal.tsx b/web/components/estimates/delete-estimate-modal.tsx index 2df848020..c9d34fe8e 100644 --- a/web/components/estimates/delete-estimate-modal.tsx +++ b/web/components/estimates/delete-estimate-modal.tsx @@ -40,16 +40,22 @@ export const DeleteEstimateModal: React.FC = observer((props) => { const estimateId = data?.id!; - projectEstimatesStore.deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId).catch((err) => { - const error = err?.error; - const errorString = Array.isArray(error) ? error[0] : error; + projectEstimatesStore + .deleteEstimate(workspaceSlug.toString(), projectId.toString(), estimateId) + .then(() => { + setIsDeleteLoading(false); + handleClose(); + }) + .catch((err) => { + const error = err?.error; + const errorString = Array.isArray(error) ? error[0] : error; - setToastAlert({ - type: "error", - title: "Error!", - message: errorString ?? "Estimate could not be deleted. Please try again", + setToastAlert({ + type: "error", + title: "Error!", + message: errorString ?? "Estimate could not be deleted. Please try again", + }); }); - }); }; useEffect(() => {