Skip to content

Commit

Permalink
🐛 (sheets) Fix can't start bot when filter is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 17, 2023
1 parent f9964e3 commit be7c0fc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const ActionOptions = ({
case GoogleSheetsAction.GET:
return (
<Stack>
{options.referenceCell ? (
{options.referenceCell && (
<>
<Text>Row to select</Text>
<CellWithValueStack
Expand All @@ -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}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
comparisons: z.array(rowsFilterComparisonSchema),
logicalOperator: z.nativeEnum(LogicalOperator),
}),
filter: z
.object({
comparisons: z.array(rowsFilterComparisonSchema),
logicalOperator: z.nativeEnum(LogicalOperator),
})
.optional(),
cellsToExtract: z.array(extractingCellSchema),
})
)
Expand Down

4 comments on commit be7c0fc

@vercel
Copy link

@vercel vercel bot commented on be7c0fc Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on be7c0fc Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
pantherview.cr8.ai
positivobra.com.br
rollingball.cr8.ai
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
ai.digitaldaftar.in
bot.boston-voip.com
92109660.therpm.club
abbonamento.bwell.it
assistent.m-vogel.de
bium.gratirabbit.com
bot.ansuraniphone.my
bot.barrettamario.it
bot.cotemeuplano.com
bot.leadbooster.help
bot.mycompay.reviews
chat.hayurihijab.com
chatbee.agfunnel.com
click.sevenoways.com
connect.growthguy.in
forms.bonanza.design
hello.advergreen.com
kuiz.sistemniaga.com
menu.numero-primo.it
offer.botscientis.us
sellmycarglasgow.com
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
abutton.wpwakanda.com
acelera.maxbot.com.br
aidigitalmarketing.kr
bbutton.wpwakanda.com
bot.coachayongzul.com
bot.digitalpointer.id
bot.eikju.photography
bot.incusservices.com
bot.meuesocial.com.br
bot.mycompany.reviews
bot.outstandbrand.com
bot.ramonmatos.com.br
bot.robertohairlab.it
bot.sharemyreview.net
bot.truongnguyen.live
botz.cloudsiteapp.com
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
criar.somaperuzzo.com
homerun.wpwakanda.com
sbutton.wpwakanda.com
www.chatgpt-biliran.com
91181264.your-access.one
abg-assistent.m-vogel.de
ai.chromebookstoreph.com
contextone.wpwakanda.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
invite.bridesquadapp.com
link.cascadigital.com.br
onboarding.growthside.io
reward.onlinebotdemo.xyz
stap.venturemarketing.in
type.opaulovieira.com.br
aibot.angrybranding.co.uk
bot.aidigitalmarketing.kr
bot.amicidisanfaustino.it
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
bot.cabinrentalagency.com
bot.fusionstarreviews.com
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
chat.ertcrebateportal.com
chat.thehomebuyersusa.com
chat.thisiscrushhouse.com
forms.hiabhaykulkarni.com
healthandsafetycourses.uk
sellmyharleylouisiana.com
testbot.sharemyreview.net
typebot-viewer.vercel.app
verfica.botmachine.com.br
bot.adventureconsulting.hu
bot2.fusionstarreviews.com
casestudyemb.wpwakanda.com
chat.atlasoutfittersk9.com
configurator.bouclidom.com
help.atlasoutfittersk9.com
herbalife.barrettamario.it
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
newsletter.itshcormeos.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br

@vercel
Copy link

@vercel vercel bot commented on be7c0fc Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on be7c0fc Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.