@@ -13,11 +13,17 @@ import {
1313} from '@opentrons/components'
1414import { useUpdateDeckConfigurationMutation } from '@opentrons/react-api-client'
1515import {
16+ FAKE_FIXTURE_IDS ,
1617 FLEX_ROBOT_TYPE ,
18+ FLEX_STACKER_FIXTURES ,
19+ getAAForModuleFixture ,
20+ getCutoutConfigReplacmentForModule ,
1721 getCutoutFixturesForModuleModel ,
1822 getDeckDefFromRobotType ,
1923 getFixtureIdByCutoutIdFromModuleAnchorCutoutId ,
2024 getModuleDisplayName ,
25+ getReplacementFixtureForFixtureRemoval ,
26+ replaceFixtureToFakeFixtureAndTransformCutoutFixturesToAA ,
2127 SINGLE_CENTER_CUTOUTS ,
2228 SINGLE_CENTER_SLOT_FIXTURE ,
2329 SINGLE_LEFT_SLOT_FIXTURE ,
@@ -46,7 +52,7 @@ export const BODY_STYLE = css`
4652 line-height : 1.75rem ;
4753 }
4854`
49- interface SelectLocationProps extends ModuleSetupWizardStepProps {
55+ export interface SelectLocationProps extends ModuleSetupWizardStepProps {
5056 deckConfig : DeckConfiguration
5157 createMaintenanceRun : CreateMaintenanceRunType
5258 isLoadedInRun : boolean
@@ -66,6 +72,11 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
6672 attachedModule ,
6773 deckConfig
6874 )
75+
76+ const deckConfigWithAA = replaceFixtureToFakeFixtureAndTransformCutoutFixturesToAA (
77+ deckConfig
78+ )
79+
6980 const { t } = useTranslation ( 'module_wizard_flows' )
7081 const moduleName = getModuleDisplayName ( attachedModule . moduleModel )
7182 const handleOnClick = ( ) : void => {
@@ -90,18 +101,22 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
90101 ( acc , { mayMountTo } ) => [ ...acc , ...mayMountTo ] ,
91102 [ ]
92103 )
93- const editableCutoutIds = deckConfig . reduce < CutoutId [ ] > (
104+
105+ const editableCutoutIds = deckConfigWithAA . reduce < CutoutId [ ] > (
94106 ( acc , { cutoutId, cutoutFixtureId, opentronsModuleSerialNumber } ) => {
95107 const isCurrentConfiguration =
96108 Object . values ( configuredFixtureIdByCutoutId ) . includes (
97109 cutoutFixtureId
98110 ) && attachedModule . serialNumber === opentronsModuleSerialNumber
99111 if (
100112 // in run setup, module calibration only available when module location is already correctly configured
101- ! isLoadedInRun &&
102- mayMountToCutoutIds . includes ( cutoutId ) &&
103- ( isCurrentConfiguration ||
104- SINGLE_SLOT_FIXTURES . includes ( cutoutFixtureId ) )
113+ ( ! isLoadedInRun &&
114+ mayMountToCutoutIds . includes ( cutoutId ) &&
115+ ( isCurrentConfiguration ||
116+ SINGLE_SLOT_FIXTURES . includes ( cutoutFixtureId ) ||
117+ // fake fixtures include mag block next to an empty staging slot and a waste chute next to an empty staging slot
118+ FAKE_FIXTURE_IDS . includes ( cutoutFixtureId ) ) ) ||
119+ FLEX_STACKER_FIXTURES . includes ( cutoutFixtureId )
105120 ) {
106121 return [ ...acc , cutoutId ]
107122 }
@@ -116,32 +131,43 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
116131 moduleFixtures
117132 )
118133 if ( ! isEqual ( selectedFixtureIdByCutoutIds , configuredFixtureIdByCutoutId ) ) {
119- updateDeckConfiguration (
120- deckConfig . map ( cc => {
121- if ( cc . cutoutId in configuredFixtureIdByCutoutId ) {
122- let replacementFixtureId : CutoutFixtureId = SINGLE_LEFT_SLOT_FIXTURE
123- if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
124- replacementFixtureId = SINGLE_CENTER_SLOT_FIXTURE
125- } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
126- replacementFixtureId = SINGLE_RIGHT_SLOT_FIXTURE
127- }
134+ const updatedDeckConfig = deckConfig . map ( cc => {
135+ if ( cc . cutoutId in configuredFixtureIdByCutoutId ) {
136+ if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
128137 return {
129138 ...cc ,
130- cutoutFixtureId : replacementFixtureId ,
139+ cutoutFixtureId : SINGLE_CENTER_SLOT_FIXTURE ,
131140 opentronsModuleSerialNumber : undefined ,
132141 }
133- } else if ( cc . cutoutId in selectedFixtureIdByCutoutIds ) {
142+ } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
134143 return {
135144 ...cc ,
136- cutoutFixtureId :
137- selectedFixtureIdByCutoutIds [ cc . cutoutId ] ?? cc . cutoutFixtureId ,
138- opentronsModuleSerialNumber : attachedModule . serialNumber ,
145+ cutoutFixtureId : SINGLE_RIGHT_SLOT_FIXTURE ,
146+ opentronsModuleSerialNumber : undefined ,
139147 }
140- } else {
141- return cc
142148 }
143- } )
144- )
149+ return {
150+ ...cc ,
151+ cutoutFixtureId : SINGLE_LEFT_SLOT_FIXTURE ,
152+ opentronsModuleSerialNumber : undefined ,
153+ }
154+ } else if ( cc . cutoutId in selectedFixtureIdByCutoutIds ) {
155+ const fixtureReplacement = getCutoutConfigReplacmentForModule (
156+ anchorCutoutId ,
157+ selectedFixtureIdByCutoutIds [ cc . cutoutId ] ?? cc . cutoutFixtureId ,
158+ attachedModule . moduleModel ,
159+ deckConfig
160+ )
161+ return {
162+ ...cc ,
163+ cutoutFixtureId : fixtureReplacement ,
164+ opentronsModuleSerialNumber : attachedModule . serialNumber ,
165+ }
166+ } else {
167+ return cc
168+ }
169+ } )
170+ updateDeckConfiguration ( updatedDeckConfig )
145171 }
146172 }
147173
@@ -153,15 +179,25 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
153179 updateDeckConfiguration (
154180 deckConfig . map ( cc => {
155181 if ( cc . cutoutId in removedFixtureIdByCutoutIds ) {
156- let replacementFixtureId : CutoutFixtureId = SINGLE_LEFT_SLOT_FIXTURE
157- if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
158- replacementFixtureId = SINGLE_CENTER_SLOT_FIXTURE
159- } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
160- replacementFixtureId = SINGLE_RIGHT_SLOT_FIXTURE
161- }
182+ const fixtureInPlace = deckConfigWithAA . find (
183+ dc => dc . cutoutId === anchorCutoutId
184+ )
185+ const removedDefaultFixture = removedFixtureIdByCutoutIds [
186+ cc . cutoutId
187+ ] as CutoutFixtureId // we know there is a match by the condition
188+ const aa = getAAForModuleFixture (
189+ anchorCutoutId ,
190+ removedDefaultFixture ,
191+ attachedModule . moduleModel
192+ )
193+ const replacment = getReplacementFixtureForFixtureRemoval (
194+ fixtureInPlace ?. cutoutFixtureId ?? removedDefaultFixture ,
195+ anchorCutoutId ,
196+ aa
197+ )
162198 return {
163199 ...cc ,
164- cutoutFixtureId : replacementFixtureId ,
200+ cutoutFixtureId : replacment ,
165201 opentronsModuleSerialNumber : undefined ,
166202 }
167203 } else {
@@ -180,6 +216,7 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
180216 handleClickAdd = { handleAddFixture }
181217 handleClickRemove = { handleRemoveFixture }
182218 editableCutoutIds = { editableCutoutIds }
219+ moduleModel = { attachedModule . moduleModel }
183220 selectedCutoutId = {
184221 deckConfig . find (
185222 ( { cutoutId, opentronsModuleSerialNumber } ) =>
0 commit comments