Skip to content

Commit

Permalink
fix fixture group display location
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Apr 4, 2024
1 parent 2df67ee commit 76a4ca9
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions app/src/organisms/DeviceDetailsDeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface DeviceDetailsDeckConfigurationProps {
robotName: string
}

function getDisplayLocationForFixtureGroup(cutouts: CutoutId[]): string {
function getDisplayLocationForCutoutIds(cutouts: CutoutId[]): string {
return cutouts.map(cutoutId => getCutoutDisplayName(cutoutId)).join(' + ')
}

Expand Down Expand Up @@ -110,7 +110,6 @@ export function DeviceDetailsDeckConfiguration({
let newDeckConfig = deckConfig
if (cutoutId in fixtureGroup) {
const groupMap = fixtureGroup[cutoutId]?.find(group => Object.entries(group).every(([cId, cfId]) => (deckConfig.find(config => config.cutoutId === cId && config.cutoutFixtureId === cfId)))) ?? {}
console.log('GROUP MAP', groupMap)
newDeckConfig = deckConfig.map(cutoutConfig => (
cutoutConfig.cutoutId in groupMap
? {
Expand Down Expand Up @@ -152,21 +151,13 @@ export function DeviceDetailsDeckConfiguration({
m => m.serialNumber === opentronsModuleSerialNumber
)?.usbPort.port
)
const fixtureGroup = getFixtureGroupForCutoutFixture(
cutoutFixtureId,
deckDef.cutoutFixtures
)
if (fixtureGroup.length > 1) {
const groupedCutoutIds = fixtureGroup
.map(
groupedFixtureId =>
deckConfig.find(cc => cc.cutoutFixtureId === groupedFixtureId)
?.cutoutId
)
.filter((cc): cc is CutoutId => cc !== null)
const displayLocation = getDisplayLocationForFixtureGroup(
groupedCutoutIds
)
const fixtureGroup =
deckDef.cutoutFixtures.find(cf => cf.id === cutoutFixtureId)
?.fixtureGroup ?? {}
if (cutoutId in fixtureGroup) {
const groupMap = fixtureGroup[cutoutId]?.find(group => Object.entries(group).every(([cId, cfId]) => (deckConfig.find(config => config.cutoutId === cId && config.cutoutFixtureId === cfId)))) ?? {}
const groupedCutoutIds = Object.keys(groupMap) as CutoutId[]
const displayLocation = getDisplayLocationForCutoutIds(groupedCutoutIds)
if (acc.groupedCutoutIds.includes(cutoutId)) {
return acc // only list grouped fixtures once
} else {
Expand All @@ -181,7 +172,7 @@ export function DeviceDetailsDeckConfiguration({
displayList: [
...acc.displayList,
{
displayLocation: getDisplayLocationForFixtureGroup([cutoutId]),
displayLocation: getDisplayLocationForCutoutIds([cutoutId]),
displayName,
},
],
Expand Down

0 comments on commit 76a4ca9

Please sign in to comment.