🐛 (sheets) Make sure update cells do not overwrite existing…

This commit is contained in:
Baptiste Arnaud
2024-06-27 11:25:43 +02:00
parent 898ed529b0
commit 1431898b82
5 changed files with 41 additions and 10 deletions

View File

@@ -0,0 +1,22 @@
import { Variable, Cell } from '@typebot.io/schemas'
import { parseVariables } from '@typebot.io/variables/parseVariables'
export const parseNewCellValuesObject =
(variables: Variable[]) =>
(
cells: Cell[],
headerValues?: string[]
): { [key: string]: { value: string; columnIndex: number } } =>
cells.reduce((row, cell) => {
return !cell.column || !cell.value
? row
: {
...row,
[cell.column]: {
value: parseVariables(variables)(cell.value),
columnIndex: headerValues?.findIndex(
(headerValue) => headerValue === cell.column
),
},
}
}, {})