🐛 (sheets) Fix can't start bot when filter is undefined
This commit is contained in:
@ -228,7 +228,7 @@ const ActionOptions = ({
|
||||
case GoogleSheetsAction.GET:
|
||||
return (
|
||||
<Stack>
|
||||
{options.referenceCell ? (
|
||||
{options.referenceCell && (
|
||||
<>
|
||||
<Text>Row to select</Text>
|
||||
<CellWithValueStack
|
||||
@ -237,12 +237,13 @@ const ActionOptions = ({
|
||||
onItemChange={handleReferenceCellChange}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
)}
|
||||
{options.filter && (
|
||||
<>
|
||||
<Text>Filter</Text>
|
||||
<RowsFilterTableList
|
||||
columns={sheet?.columns ?? []}
|
||||
filter={options.filter}
|
||||
filter={options.filter ?? {}}
|
||||
onFilterChange={handleFilterChange}
|
||||
/>
|
||||
</>
|
||||
|
@ -136,9 +136,7 @@ test.describe.parallel('Google sheets integration', () => {
|
||||
.press('Enter')
|
||||
await expect(
|
||||
page.locator('typebot-standard').locator('text=Your name is:')
|
||||
).toHaveText(
|
||||
`Your name is: ["Georges","John","Fred","Georges","Georges"] ["Last name","Smith","Smith"]`
|
||||
)
|
||||
).toHaveText(`Your name is: Georges Smith`)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -43,7 +43,7 @@ export const getRow = async (
|
||||
const filteredRows = rows.filter((row) =>
|
||||
referenceCell
|
||||
? row[referenceCell.column as string] === referenceCell.value
|
||||
: matchFilter(row, filter)
|
||||
: matchFilter(row, filter as NonNullable<typeof filter>)
|
||||
)
|
||||
if (filteredRows.length === 0) {
|
||||
log = {
|
||||
@ -104,7 +104,7 @@ export const getRow = async (
|
||||
|
||||
const matchFilter = (
|
||||
row: GoogleSpreadsheetRow,
|
||||
filter: GoogleSheetsGetOptions['filter']
|
||||
filter: NonNullable<GoogleSheetsGetOptions['filter']>
|
||||
) => {
|
||||
return filter.logicalOperator === LogicalOperator.AND
|
||||
? filter.comparisons.every(
|
||||
|
@ -75,7 +75,7 @@ const getRows = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const filteredRows = rows.filter((row) =>
|
||||
referenceCell
|
||||
? row[referenceCell.column as string] === referenceCell.value
|
||||
: matchFilter(row, filter)
|
||||
: matchFilter(row, filter as NonNullable<typeof filter>)
|
||||
)
|
||||
if (filteredRows.length === 0) {
|
||||
await saveErrorLog({
|
||||
@ -181,7 +181,7 @@ const updateRow = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
|
||||
const matchFilter = (
|
||||
row: GoogleSpreadsheetRow,
|
||||
filter: GoogleSheetsGetOptions['filter']
|
||||
filter: NonNullable<GoogleSheetsGetOptions['filter']>
|
||||
) => {
|
||||
return filter.logicalOperator === LogicalOperator.AND
|
||||
? filter.comparisons.every(
|
||||
|
@ -40,10 +40,12 @@ const googleSheetsGetOptionsSchema = googleSheetsOptionsBaseSchema.merge(
|
||||
action: z.enum([GoogleSheetsAction.GET]),
|
||||
// TODO: remove referenceCell once migrated to filtering
|
||||
referenceCell: cellSchema.optional(),
|
||||
filter: z.object({
|
||||
filter: z
|
||||
.object({
|
||||
comparisons: z.array(rowsFilterComparisonSchema),
|
||||
logicalOperator: z.nativeEnum(LogicalOperator),
|
||||
}),
|
||||
})
|
||||
.optional(),
|
||||
cellsToExtract: z.array(extractingCellSchema),
|
||||
})
|
||||
)
|
||||
|
Reference in New Issue
Block a user