From d30a88832af99d51ff601cdce187e99d4960dab3 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 20 Apr 2023 12:09:35 +0530 Subject: [PATCH] fix: reset estimates modal form after create/update (#893) --- .../estimates/create-update-estimate-modal.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/app/components/estimates/create-update-estimate-modal.tsx b/apps/app/components/estimates/create-update-estimate-modal.tsx index a8a191eca..92c32a1c2 100644 --- a/apps/app/components/estimates/create-update-estimate-modal.tsx +++ b/apps/app/components/estimates/create-update-estimate-modal.tsx @@ -41,6 +41,11 @@ export const CreateUpdateEstimateModal: React.FC = ({ handleClose, data, defaultValues, }); + const onClose = () => { + handleClose(); + reset(); + }; + const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -62,7 +67,6 @@ export const CreateUpdateEstimateModal: React.FC = ({ handleClose, data, (prevData) => [res, ...(prevData ?? [])], false ); - handleClose(); }) .catch(() => { setToastAlert({ @@ -71,6 +75,8 @@ export const CreateUpdateEstimateModal: React.FC = ({ handleClose, data, message: "Error: Estimate could not be created", }); }); + + onClose(); }; const updateEstimate = async (formData: IEstimate) => { @@ -102,7 +108,8 @@ export const CreateUpdateEstimateModal: React.FC = ({ handleClose, data, message: "Error: Estimate could not be updated", }); }); - handleClose(); + + onClose(); }; useEffect(() => {