2023-03-15 12:21:52 +01:00
|
|
|
import { Variable, Cell } from '@typebot.io/schemas'
|
2023-12-13 10:22:02 +01:00
|
|
|
import { parseVariables } from '@typebot.io/variables/parseVariables'
|
2023-03-15 12:21:52 +01:00
|
|
|
|
|
|
|
|
export const parseCellValues =
|
|
|
|
|
(variables: Variable[]) =>
|
|
|
|
|
(cells: Cell[]): { [key: string]: string } =>
|
|
|
|
|
cells.reduce((row, cell) => {
|
|
|
|
|
return !cell.column || !cell.value
|
|
|
|
|
? row
|
|
|
|
|
: {
|
|
|
|
|
...row,
|
|
|
|
|
[cell.column]: parseVariables(variables)(cell.value),
|
|
|
|
|
}
|
|
|
|
|
}, {})
|