Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): e-stop modal button state issue #14217

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { 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 @@
}: 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 @@
}

const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e): void => {
e.preventDefault()

Check warning on line 154 in app/src/organisms/EmergencyStop/EstopPressedModal.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/EmergencyStop/EstopPressedModal.tsx#L154

Added line #L154 was not covered by tests
setIsResuming(true)
acknowledgeEstopDisengage({
onSuccess: () => {},
onSuccess: () => {
closeModal()

Check warning on line 158 in app/src/organisms/EmergencyStop/EstopPressedModal.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/EmergencyStop/EstopPressedModal.tsx#L158

Added line #L158 was not covered by tests
},
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
Loading