Skip to content

Commit 8f5e32b

Browse files
committed
refactor(components): default to empty string if params not supplied
1 parent f5b9bdf commit 8f5e32b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

components/src/organisms/CommandText/useCommandTextString/utils/commandText/getMoveToWellCommandText.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function getMoveToWellCommandText({
1717
x: xOffsetUnformatted,
1818
y: yOffsetUnformatted,
1919
z: zOffsetUnformatted,
20-
} = wellLocation.offset
20+
} = wellLocation?.offset ?? { x: '', y: '', z: '' }
2121
const allPreviousCommands = commandTextData?.commands.slice(
2222
0,
2323
commandTextData.commands.findIndex(c => c.id === command.id)
@@ -36,6 +36,13 @@ export function getMoveToWellCommandText({
3636
t,
3737
})
3838

39+
const xOffset =
40+
typeof xOffsetUnformatted === 'number' ? xOffsetUnformatted?.toFixed(2) : ''
41+
const yOffset =
42+
typeof yOffsetUnformatted === 'number' ? yOffsetUnformatted?.toFixed(2) : ''
43+
const zOffset =
44+
typeof zOffsetUnformatted === 'number' ? zOffsetUnformatted?.toFixed(2) : ''
45+
3946
return t('move_to_well', {
4047
wellName,
4148
labware:
@@ -46,10 +53,10 @@ export function getMoveToWellCommandText({
4653
allRunDefs,
4754
})
4855
: null,
49-
xOffset: xOffsetUnformatted.toFixed(2),
50-
yOffset: yOffsetUnformatted.toFixed(2),
51-
zOffset: zOffsetUnformatted.toFixed(2),
52-
positionRelative: wellLocation.origin,
56+
xOffset,
57+
yOffset,
58+
zOffset,
59+
positionRelative: wellLocation?.origin,
5360
displayLocation,
5461
})
5562
}

shared-data/command/types/support.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface WellOffset {
55
y?: number
66
z?: number
77
}
8+
// TODO(jh, 06-27-25): Origin and offset should be required. Mark them as so and fix all the type errors.
89
export interface WellLocation {
910
origin?: WellOrigin
1011
offset?: WellOffset

0 commit comments

Comments
 (0)