fix: reset estimates modal form after create/update (#893)

This commit is contained in:
Aaryan Khandelwal 2023-04-20 12:09:35 +05:30 committed by GitHub
parent ebce364104
commit d30a88832a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,11 @@ export const CreateUpdateEstimateModal: React.FC<Props> = ({ handleClose, data,
defaultValues, defaultValues,
}); });
const onClose = () => {
handleClose();
reset();
};
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
@ -62,7 +67,6 @@ export const CreateUpdateEstimateModal: React.FC<Props> = ({ handleClose, data,
(prevData) => [res, ...(prevData ?? [])], (prevData) => [res, ...(prevData ?? [])],
false false
); );
handleClose();
}) })
.catch(() => { .catch(() => {
setToastAlert({ setToastAlert({
@ -71,6 +75,8 @@ export const CreateUpdateEstimateModal: React.FC<Props> = ({ handleClose, data,
message: "Error: Estimate could not be created", message: "Error: Estimate could not be created",
}); });
}); });
onClose();
}; };
const updateEstimate = async (formData: IEstimate) => { const updateEstimate = async (formData: IEstimate) => {
@ -102,7 +108,8 @@ export const CreateUpdateEstimateModal: React.FC<Props> = ({ handleClose, data,
message: "Error: Estimate could not be updated", message: "Error: Estimate could not be updated",
}); });
}); });
handleClose();
onClose();
}; };
useEffect(() => { useEffect(() => {