From 5115c8169b42a931cf587c0818c24dbd1874287c Mon Sep 17 00:00:00 2001 From: koji Date: Fri, 15 Dec 2023 13:15:21 -0500 Subject: [PATCH] fix(app): fix estop modal button status issue remove useEffect to avoid unexpected state change close RQA-2111 --- .../EmergencyStop/EstopPressedModal.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/app/src/organisms/EmergencyStop/EstopPressedModal.tsx b/app/src/organisms/EmergencyStop/EstopPressedModal.tsx index 5c80dab272a..0c2b46fdc3d 100644 --- a/app/src/organisms/EmergencyStop/EstopPressedModal.tsx +++ b/app/src/organisms/EmergencyStop/EstopPressedModal.tsx @@ -133,10 +133,7 @@ function DesktopModal({ }: EstopPressedModalProps): JSX.Element { const { t } = useTranslation('device_settings') const [isResuming, setIsResuming] = React.useState(false) - const { - acknowledgeEstopDisengage, - data, - } = useAcknowledgeEstopDisengageMutation() + const { acknowledgeEstopDisengage } = useAcknowledgeEstopDisengageMutation() const handleCloseModal = (): void => { if (setIsDismissedModal != null) { @@ -155,21 +152,18 @@ function DesktopModal({ } const handleClick: React.MouseEventHandler = (e): void => { + e.preventDefault() setIsResuming(true) acknowledgeEstopDisengage({ - onSuccess: () => {}, + onSuccess: () => { + closeModal() + }, onError: () => { setIsResuming(false) }, }) } - React.useEffect(() => { - if (data?.data.status === DISENGAGED) { - closeModal() - } - }, [data?.data.status, closeModal]) - return (