diff --git a/app/src/organisms/GripperWizardFlows/index.tsx b/app/src/organisms/GripperWizardFlows/index.tsx index 1c3126c739d..d0cd8073de2 100644 --- a/app/src/organisms/GripperWizardFlows/index.tsx +++ b/app/src/organisms/GripperWizardFlows/index.tsx @@ -2,7 +2,6 @@ import * as React from 'react' import { createPortal } from 'react-dom' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import { UseMutateFunction } from 'react-query' import { useConditionalConfirm, Flex, @@ -35,6 +34,7 @@ import { UnmountGripper } from './UnmountGripper' import { Success } from './Success' import { ExitConfirmation } from './ExitConfirmation' +import type { UseMutateFunction } from 'react-query' import type { GripperWizardFlowType } from './types' import type { AxiosError } from 'axios' import type { @@ -120,11 +120,18 @@ export function GripperWizardFlows( if (props?.onComplete != null) props.onComplete() if (maintenanceRunData != null) { deleteMaintenanceRun(maintenanceRunData?.data.id) + } else { + closeFlow() } - closeFlow() } - const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({}) + const { + deleteMaintenanceRun, + isLoading: isDeleteLoading, + } = useDeleteMaintenanceRunMutation({ + onSuccess: () => closeFlow(), + onError: () => closeFlow(), + }) const handleCleanUpAndClose = (): void => { if (maintenanceRunData?.data.id == null) handleClose() @@ -153,7 +160,10 @@ export function GripperWizardFlows( createMaintenanceRun={createTargetedMaintenanceRun} isCreateLoading={isCreateLoading} isRobotMoving={ - isChainCommandMutationLoading || isCommandLoading || isExiting + isChainCommandMutationLoading || + isCommandLoading || + isExiting || + isDeleteLoading } handleCleanUpAndClose={handleCleanUpAndClose} handleClose={handleClose} diff --git a/app/src/organisms/PipetteWizardFlows/index.tsx b/app/src/organisms/PipetteWizardFlows/index.tsx index 337a51028ed..d1bec49c543 100644 --- a/app/src/organisms/PipetteWizardFlows/index.tsx +++ b/app/src/organisms/PipetteWizardFlows/index.tsx @@ -5,13 +5,7 @@ import { useTranslation } from 'react-i18next' import NiceModal, { useModal } from '@ebay/nice-modal-react' import { useConditionalConfirm, COLORS } from '@opentrons/components' -import { - LEFT, - NINETY_SIX_CHANNEL, - RIGHT, - LoadedPipette, - CreateCommand, -} from '@opentrons/shared-data' +import { LEFT, NINETY_SIX_CHANNEL, RIGHT } from '@opentrons/shared-data' import { useHost, useDeleteMaintenanceRunMutation, @@ -28,6 +22,7 @@ import { getTopPortalEl } from '../../App/portal' import { WizardHeader } from '../../molecules/WizardHeader' import { FirmwareUpdateModal } from '../FirmwareUpdateModal' import { getIsOnDevice } from '../../redux/config' +import { SimpleWizardBody } from '../../molecules/SimpleWizardBody' import { useAttachedPipettesFromInstrumentsQuery } from '../Devices/hooks' import { usePipetteFlowWizardHeaderText } from './hooks' import { getPipetteWizardSteps } from './getPipetteWizardSteps' @@ -44,10 +39,13 @@ import { Carriage } from './Carriage' import { MountingPlate } from './MountingPlate' import { UnskippableModal } from './UnskippableModal' -import type { PipetteMount } from '@opentrons/shared-data' +import type { + LoadedPipette, + CreateCommand, + PipetteMount, +} from '@opentrons/shared-data' import type { CommandData, HostConfig } from '@opentrons/api-client' import type { PipetteWizardFlow, SelectablePipettes } from './types' -import { SimpleWizardBody } from '../../molecules/SimpleWizardBody' const RUN_REFETCH_INTERVAL = 5000 @@ -185,11 +183,18 @@ export const PipetteWizardFlows = ( if (onComplete != null) onComplete() if (maintenanceRunData != null) { deleteMaintenanceRun(maintenanceRunData?.data.id) + } else { + closeFlow() } - closeFlow() } - const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({}) + const { + deleteMaintenanceRun, + isLoading: isDeleteLoading, + } = useDeleteMaintenanceRunMutation({ + onSuccess: () => closeFlow(), + onError: () => closeFlow(), + }) const handleCleanUpAndClose = (): void => { if (maintenanceRunData?.data.id == null) handleClose() @@ -234,7 +239,7 @@ export const PipetteWizardFlows = ( : undefined const calibrateBaseProps = { chainRunCommands: chainMaintenanceRunCommands, - isRobotMoving: isCommandMutationLoading, + isRobotMoving: isCommandMutationLoading || isDeleteLoading, proceed, maintenanceRunId, goBack, @@ -255,11 +260,11 @@ export const PipetteWizardFlows = ( proceed={handleCleanUpAndClose} goBack={cancelExit} isOnDevice={isOnDevice} - isRobotMoving={isCommandMutationLoading} + isRobotMoving={isCommandMutationLoading || isDeleteLoading} /> ) : (