From 3e1ba3e6bbc6adae71a71dd32f6f1a18d0ee4c4c Mon Sep 17 00:00:00 2001 From: smb2268 Date: Thu, 2 May 2024 16:36:26 -0400 Subject: [PATCH] Updated linting and ts errors --- .../QuickTransferFlow/SelectDestLabware.tsx | 4 ++-- .../QuickTransferFlow/SelectDestWells.tsx | 2 +- .../QuickTransferFlow/SelectPipette.tsx | 1 - .../QuickTransferFlow/SelectSourceLabware.tsx | 4 ++-- .../QuickTransferFlow/VolumeEntry.tsx | 4 ++-- .../QuickTransferFlow/__tests__/utils.test.ts | 2 +- app/src/organisms/QuickTransferFlow/utils.ts | 19 ++++++++++++------- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/src/organisms/QuickTransferFlow/SelectDestLabware.tsx b/app/src/organisms/QuickTransferFlow/SelectDestLabware.tsx index dcd08680bc2..b996053845c 100644 --- a/app/src/organisms/QuickTransferFlow/SelectDestLabware.tsx +++ b/app/src/organisms/QuickTransferFlow/SelectDestLabware.tsx @@ -34,18 +34,18 @@ export function SelectDestLabware( ): JSX.Element | null { const { onNext, onBack, exitButtonProps, state, dispatch } = props const { i18n, t } = useTranslation(['quick_transfer', 'shared']) + if (state.pipette == null) return null const labwareDisplayCategoryFilters: LabwareFilter[] = [ 'all', 'wellPlate', 'reservoir', ] - if (state.pipette?.channels === 1) { + if (state.pipette.channels === 1) { labwareDisplayCategoryFilters.push('tubeRack') } const [selectedCategory, setSelectedCategory] = React.useState( 'all' ) - if (state.pipette == null) return null const compatibleLabwareDefinitions = getCompatibleLabwareByCategory( state.pipette.channels, selectedCategory diff --git a/app/src/organisms/QuickTransferFlow/SelectDestWells.tsx b/app/src/organisms/QuickTransferFlow/SelectDestWells.tsx index 218d0954a99..39ef17cffe9 100644 --- a/app/src/organisms/QuickTransferFlow/SelectDestWells.tsx +++ b/app/src/organisms/QuickTransferFlow/SelectDestWells.tsx @@ -29,7 +29,7 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element { type: 'SET_DEST_WELLS', wells: Object.keys(state.source.wells), }) - } else if (state.destination != 'source' && state.destination != null) { + } else if (state.destination !== 'source' && state.destination != null) { dispatch({ type: 'SET_DEST_WELLS', wells: Object.keys(state.destination.wells), diff --git a/app/src/organisms/QuickTransferFlow/SelectPipette.tsx b/app/src/organisms/QuickTransferFlow/SelectPipette.tsx index f919eb7f6f0..6ef31157fdf 100644 --- a/app/src/organisms/QuickTransferFlow/SelectPipette.tsx +++ b/app/src/organisms/QuickTransferFlow/SelectPipette.tsx @@ -11,7 +11,6 @@ import { useInstrumentsQuery } from '@opentrons/react-api-client' import { getPipetteSpecsV2, RIGHT, LEFT } from '@opentrons/shared-data' import { SmallButton, LargeButton } from '../../atoms/buttons' import { ChildNavigation } from '../ChildNavigation' -import { generateCompatibleLabwareForPipette } from './utils' import type { PipetteData, Mount } from '@opentrons/api-client' import type { diff --git a/app/src/organisms/QuickTransferFlow/SelectSourceLabware.tsx b/app/src/organisms/QuickTransferFlow/SelectSourceLabware.tsx index 5a450fce2ac..95e623be5cd 100644 --- a/app/src/organisms/QuickTransferFlow/SelectSourceLabware.tsx +++ b/app/src/organisms/QuickTransferFlow/SelectSourceLabware.tsx @@ -34,18 +34,18 @@ export function SelectSourceLabware( ): JSX.Element | null { const { onNext, onBack, exitButtonProps, state, dispatch } = props const { i18n, t } = useTranslation(['quick_transfer', 'shared']) + if (state.pipette == null) return null const labwareDisplayCategoryFilters: LabwareFilter[] = [ 'all', 'wellPlate', 'reservoir', ] - if (state.pipette?.channels === 1) { + if (state.pipette.channels === 1) { labwareDisplayCategoryFilters.push('tubeRack') } const [selectedCategory, setSelectedCategory] = React.useState( 'all' ) - if (state.pipette == null) return null const compatibleLabwareDefinitions = getCompatibleLabwareByCategory( state.pipette.channels, diff --git a/app/src/organisms/QuickTransferFlow/VolumeEntry.tsx b/app/src/organisms/QuickTransferFlow/VolumeEntry.tsx index 84b807eed21..0613aac652a 100644 --- a/app/src/organisms/QuickTransferFlow/VolumeEntry.tsx +++ b/app/src/organisms/QuickTransferFlow/VolumeEntry.tsx @@ -65,7 +65,7 @@ export function VolumeEntry(props: VolumeEntryProps): JSX.Element { } const error = - volume != '' && + volume !== '' && (volumeAsNumber < volumeRange.min || volumeAsNumber > volumeRange.max) ? t(`value_out_of_range`, { min: volumeRange.min, @@ -82,7 +82,7 @@ export function VolumeEntry(props: VolumeEntryProps): JSX.Element { onClickButton={handleClickNext} secondaryButtonProps={exitButtonProps} top={SPACING.spacing8} - buttonIsDisabled={error != null || volume == ''} + buttonIsDisabled={error != null || volume === ''} /> { - let state: QuickTransferSetupState = { + const state: QuickTransferSetupState = { pipette: { liquids: [ { diff --git a/app/src/organisms/QuickTransferFlow/utils.ts b/app/src/organisms/QuickTransferFlow/utils.ts index caab760bb2b..907c08a52a6 100644 --- a/app/src/organisms/QuickTransferFlow/utils.ts +++ b/app/src/organisms/QuickTransferFlow/utils.ts @@ -151,15 +151,20 @@ export function getVolumeLimits( const maxPipetteVolume = Object.values(state.pipette.liquids)[0].maxVolume const tipRackVolume = Object.values(state.tipRack.wells)[0].totalLiquidVolume const sourceLabwareVolume = Math.min( - ...state.sourceWells.map(well => state.source.wells[well].totalLiquidVolume) + ...state.sourceWells.map(well => + state.source ? state.source.wells[well].totalLiquidVolume : 0 + ) ) const destLabwareVolume = Math.min( - ...state.destinationWells.map(well => - state.destination === 'source' - ? state.source.wells[well].totalLiquidVolume - : state.destination.wells[well].totalLiquidVolume - ) + ...state.destinationWells.map(well => { + { + if (state.source == null || state.destination == null) return 0 + return state.destination === 'source' + ? state.source.wells[well].totalLiquidVolume + : state.destination.wells[well].totalLiquidVolume + } + }) ) let maxVolume = maxPipetteVolume if (state.sourceWells.length === state.destinationWells.length) { @@ -210,7 +215,7 @@ export function generateCompatibleLabwareForPipette( const compatibleDefUriList = allLabwareDefinitions.reduce( (acc, definition) => { - if (pipetteSpecs.channels == 1) { + if (pipetteSpecs.channels === 1) { return [...acc, getLabwareDefURI(definition)] } else { const isCompatible = canPipetteUseLabware(pipetteSpecs, definition)