Skip to content

Commit

Permalink
implement basic destination well selection
Browse files Browse the repository at this point in the history
  • Loading branch information
brenthagen committed May 16, 2024
1 parent a52fff1 commit bcc1186
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
61 changes: 41 additions & 20 deletions app/src/organisms/QuickTransferFlow/SelectDestWells.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { Flex, SPACING } from '@opentrons/components'
import { Flex, JUSTIFY_CENTER, SPACING } from '@opentrons/components'

import { SmallButton } from '../../atoms/buttons'
import { ChildNavigation } from '../ChildNavigation'
import { WellSelection } from '../../organisms/WellSelection'

import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardAction,
Expand All @@ -13,47 +14,67 @@ import type {
interface SelectDestWellsProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
const { onNext, onBack, exitButtonProps, state, dispatch } = props
const { onNext, onBack, state, dispatch } = props
const { i18n, t } = useTranslation(['quick_transfer', 'shared'])

const destinationWells = state.destinationWells ?? []
const destinationWellGroup = destinationWells.reduce((acc, well) => {
return { ...acc, [well]: null }
}, {})

const [selectedWells, setSelectedWells] = React.useState(destinationWellGroup)

const handleClickNext = (): void => {
// until well selection is implemented, select all wells and proceed to the next step
if (state.destination === 'source' && state.source != null) {
dispatch({
type: 'SET_DEST_WELLS',
wells: Object.keys(state.source.wells),
})
} else if (state.destination !== 'source' && state.destination != null) {
dispatch({
type: 'SET_DEST_WELLS',
wells: Object.keys(state.destination.wells),
})
}
dispatch({
type: 'SET_DEST_WELLS',
wells: Object.keys(selectedWells),
})
onNext()
}

const resetButtonProps: React.ComponentProps<typeof SmallButton> = {
buttonType: 'tertiaryLowLight',
buttonText: t('shared:reset'),
onClick: () => {
setSelectedWells({})
},
}

return (
<Flex>
<>
<ChildNavigation
header={t('select_dest_wells')}
onClickBack={onBack}
buttonText={i18n.format(t('shared:continue'), 'capitalize')}
onClickButton={handleClickNext}
buttonIsDisabled={false}
secondaryButtonProps={exitButtonProps}
secondaryButtonProps={resetButtonProps}
top={SPACING.spacing8}
/>
<Flex
justifyContent={JUSTIFY_CENTER}
marginTop={SPACING.spacing120}
padding={`${SPACING.spacing16} ${SPACING.spacing60} ${SPACING.spacing40} ${SPACING.spacing60}`}
>
TODO: Add destination well selection deck map
{state.destination != null && state.source != null ? (
<WellSelection
definition={
state.destination === 'source' ? state.source : state.destination
}
selectedPrimaryWells={selectedWells}
selectWells={wellGroup => {
setSelectedWells(prevWells => ({ ...prevWells, ...wellGroup }))
}}
// TODO: nozzle type
nozzleType={null}
/>
) : null}
</Flex>
</Flex>
</>
)
}
2 changes: 1 addition & 1 deletion app/src/organisms/QuickTransferFlow/SelectSourceWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {
interface SelectSourceWellsProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
dispatch: React.Dispatch<QuickTransferWizardAction>
}
Expand Down Expand Up @@ -70,6 +69,7 @@ export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
selectWells={wellGroup => {
setSelectedWells(prevWells => ({ ...prevWells, ...wellGroup }))
}}
// TODO: nozzle type
nozzleType={null}
/>
) : null}
Expand Down

0 comments on commit bcc1186

Please sign in to comment.