Skip to content

Commit

Permalink
fix(app): fix estop modal button status issue
Browse files Browse the repository at this point in the history
remove useEffect to avoid unexpected state change

close RQA-2111
  • Loading branch information
koji committed Dec 15, 2023
1 parent a7d1187 commit 5115c81
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions app/src/organisms/EmergencyStop/EstopPressedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ function DesktopModal({
}: EstopPressedModalProps): JSX.Element {
const { t } = useTranslation('device_settings')
const [isResuming, setIsResuming] = React.useState<boolean>(false)
const {
acknowledgeEstopDisengage,
data,
} = useAcknowledgeEstopDisengageMutation()
const { acknowledgeEstopDisengage } = useAcknowledgeEstopDisengageMutation()

const handleCloseModal = (): void => {
if (setIsDismissedModal != null) {
Expand All @@ -155,21 +152,18 @@ function DesktopModal({
}

const handleClick: React.MouseEventHandler<HTMLButtonElement> = (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 (
<LegacyModal {...modalProps}>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing24}>
Expand Down

0 comments on commit 5115c81

Please sign in to comment.