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