Skip to content

Commit

Permalink
fix(app): e-stop modal button state issue (#14217)
Browse files Browse the repository at this point in the history
* fix(app): fix estop modal button state issue
  • Loading branch information
koji authored Dec 15, 2023
1 parent 9842207 commit ef937ee
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions app/src/organisms/EmergencyStop/EstopPressedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { StyledText } from '../../atoms/text'
import { LegacyModal } from '../../molecules/LegacyModal'
import { Modal } from '../../molecules/Modal'
import { getIsOnDevice } from '../../redux/config'
import { DISENGAGED } from './constants'

import type {
ModalHeaderBaseProps,
Expand Down Expand Up @@ -133,10 +132,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 +151,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 ef937ee

Please sign in to comment.