🐛 (sheets) Correctly parse variables when getting data
This commit is contained in:
@ -136,7 +136,9 @@ test.describe.parallel('Google sheets integration', () => {
|
||||
.press('Enter')
|
||||
await expect(
|
||||
page.locator('typebot-standard').locator('text=Your name is:')
|
||||
).toHaveText(/John|Fred|Georges/)
|
||||
).toHaveText(
|
||||
`Your name is: ["Georges","John","Fred","Georges","Georges"] ["Last name","Smith","Smith"]`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
} from 'models'
|
||||
import { saveErrorLog } from '@/features/logs/api'
|
||||
import { getAuthenticatedGoogleDoc } from './helpers'
|
||||
import { updateVariables } from '@/features/variables'
|
||||
import { deepParseVariable, updateVariables } from '@/features/variables'
|
||||
import { isNotEmpty, byId, isDefined } from 'utils'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
import type { GoogleSpreadsheetRow } from 'google-spreadsheet'
|
||||
@ -20,7 +20,9 @@ export const getRow = async (
|
||||
options,
|
||||
}: { outgoingEdgeId?: string; options: GoogleSheetsGetOptions }
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
const { sheetId, cellsToExtract, referenceCell, filter } = options
|
||||
const { sheetId, cellsToExtract, referenceCell, filter } = deepParseVariable(
|
||||
state.typebot.variables
|
||||
)(options)
|
||||
if (!sheetId) return { outgoingEdgeId }
|
||||
|
||||
let log: ReplyLog | undefined
|
||||
|
@ -2,7 +2,7 @@ import { SessionState, GoogleSheetsUpdateRowOptions, ReplyLog } from 'models'
|
||||
import { saveErrorLog, saveSuccessLog } from '@/features/logs/api'
|
||||
import { getAuthenticatedGoogleDoc, parseCellValues } from './helpers'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { deepParseVariable } from '@/features/variables'
|
||||
import { ExecuteIntegrationResponse } from '@/features/chat'
|
||||
|
||||
export const updateRow = async (
|
||||
@ -12,7 +12,7 @@ export const updateRow = async (
|
||||
options,
|
||||
}: { outgoingEdgeId?: string; options: GoogleSheetsUpdateRowOptions }
|
||||
): Promise<ExecuteIntegrationResponse> => {
|
||||
const { sheetId, referenceCell } = options
|
||||
const { sheetId, referenceCell } = deepParseVariable(variables)(options)
|
||||
if (!options.cellsToUpsert || !sheetId || !referenceCell)
|
||||
return { outgoingEdgeId }
|
||||
|
||||
@ -23,10 +23,6 @@ export const updateRow = async (
|
||||
spreadsheetId: options.spreadsheetId,
|
||||
})
|
||||
|
||||
const parsedReferenceCell = {
|
||||
column: referenceCell.column,
|
||||
value: parseVariables(variables)(referenceCell.value),
|
||||
}
|
||||
const parsedValues = parseCellValues(variables)(options.cellsToUpsert)
|
||||
|
||||
try {
|
||||
@ -34,8 +30,7 @@ export const updateRow = async (
|
||||
const sheet = doc.sheetsById[sheetId]
|
||||
const rows = await sheet.getRows()
|
||||
const updatingRowIndex = rows.findIndex(
|
||||
(row) =>
|
||||
row[parsedReferenceCell.column as string] === parsedReferenceCell.value
|
||||
(row) => row[referenceCell.column as string] === referenceCell.value
|
||||
)
|
||||
if (updatingRowIndex === -1) {
|
||||
new TRPCError({
|
||||
|
Reference in New Issue
Block a user