Skip to content

Commit 18f4b30

Browse files
committed
chore: use types in variable processing
1 parent c2e10e8 commit 18f4b30

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

packages/frontend/src/components/FlowStepTestController/TestMultiRowResultModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default function TestMultiRowResultModal(
147147
<Tbody>
148148
{dataRows.map((row, index) => (
149149
<TableRow
150-
key={row.id || row.rowId}
150+
key={row.rowId ?? `${row.id}-${index}`}
151151
row={row}
152152
index={index}
153153
columns={columns}

packages/frontend/src/components/MultiRowResultVariables/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { Variable } from '@/helpers/variables'
44

55
import { ExecutionStepDataOutSchema, VariableToRowDataSchema } from './schema'
66

7-
interface RawColumn {
7+
export interface RawColumn {
88
id: string
99
name: string
1010
value: string
1111
}
1212

13-
interface RawRow {
13+
export interface RawRow {
1414
data: Record<string, string | number>
1515
rowId?: string // only Tiles will have this
1616
}

packages/frontend/src/helpers/variables.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type {
77

88
import get from 'lodash.get'
99

10+
import { RawColumn, RawRow } from '@/components/MultiRowResultVariables/utils'
11+
1012
// these are the variable types to display on the frontend (make visible)
1113
export const VISIBLE_VARIABLE_TYPES: TDataOutMetadatumType[] = [
1214
'text',
@@ -126,7 +128,7 @@ const process = (
126128
})
127129
}
128130

129-
// special handling for Tiles multiple row
131+
// special handling for multiple row objects from Tiles and M365 Excel
130132
// we do not do not join like strings as it contains objects and do not flatmap the data as we want to use it as a whole
131133
if (type === 'multiple-row-object') {
132134
const { columns, rows } = data
@@ -145,29 +147,27 @@ const process = (
145147
* NOTE: we dynamically obtain the values for each column since we are not
146148
* storing the values in the dataOut.
147149
*/
148-
const columnVariables = columns.map(
149-
(column: { id: string; name: string; value?: string }) => {
150-
const rowValues: string[] = []
151-
rows.forEach((row: { data: Record<string, string> }) => {
152-
/**
153-
* NOTE: do not push empty values as we do not want to cause any errors
154-
* that may arise from having empty values.
155-
*/
156-
if (row.data[column.id]) {
157-
rowValues.push(row.data[column.id])
158-
}
159-
})
160-
161-
return {
162-
...column,
163-
name: `step.${stepId}.${column.value}`,
164-
label: column.name,
165-
displayedValue: rowValues.join(', '),
166-
value: rowValues.join(', '),
167-
type: 'text',
150+
const columnVariables = columns.map((column: RawColumn) => {
151+
const rowValues: (string | number)[] = []
152+
rows.forEach((row: RawRow) => {
153+
/**
154+
* NOTE: do not push empty values as we do not want to cause any errors
155+
* that may arise from having empty values.
156+
*/
157+
if (row.data[column.id]) {
158+
rowValues.push(row.data[column.id])
168159
}
169-
},
170-
)
160+
})
161+
162+
return {
163+
...column,
164+
name: `step.${stepId}.${column.value}`,
165+
label: column.name,
166+
displayedValue: rowValues.join(', '),
167+
value: rowValues.join(', '),
168+
type: 'text',
169+
}
170+
})
171171

172172
return [...outputVars, ...columnVariables]
173173
}

0 commit comments

Comments
 (0)