Skip to content

Commit

Permalink
🚑 (results) Fix results display when variable has null value
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Nov 22, 2022
1 parent 11695ef commit e6dceca
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ModalContent,
ModalOverlay,
} from '@chakra-ui/react'
import { GraphNavigation } from 'db'
import React from 'react'
import { EditorSettingsForm } from './EditorSettingsForm'

Expand All @@ -23,9 +24,11 @@ export const EditorSettingsModal = ({ isOpen, onClose }: Props) => {
<ModalContent>
<ModalCloseButton />
<ModalBody pt="12" pb="8" px="8">
{user?.graphNavigation && (
<EditorSettingsForm defaultGraphNavigation={user.graphNavigation} />
)}
<EditorSettingsForm
defaultGraphNavigation={
user?.graphNavigation ?? GraphNavigation.TRACKPAD
}
/>
</ModalBody>
</ModalContent>
</Modal>
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/features/results/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const convertResultsToTableData = (
}
}
const variable = answerOrVariable as VariableWithValue
if (variable.value === null) return o
const key = headerCells.find((headerCell) =>
headerCell.variableIds?.includes(variable.id)
)?.label
Expand Down
8 changes: 1 addition & 7 deletions apps/viewer/src/components/TypebotPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { TypebotViewer } from 'bot-engine'
import {
Answer,
AnswerInput,
PublicTypebot,
Typebot,
VariableWithValue,
} from 'models'
import { AnswerInput, PublicTypebot, Typebot, VariableWithValue } from 'models'
import { useRouter } from 'next/router'
import React, { useEffect, useState } from 'react'
import { isDefined, isNotDefined } from 'utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-engine/src/features/variables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const parseVariables =
const variable = variables.find((v) => {
return matchedVarName === v.name && isDefined(v.value)
}) as VariableWithValue | undefined
if (!variable) return ''
if (!variable || variable.value === null) return ''
if (options.fieldToParse === 'id') return variable.id
const { value } = variable
if (options.escapeForJson) return jsonParse(value)
Expand Down
2 changes: 1 addition & 1 deletion packages/models/src/features/typebot/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const variableSchema = z.object({
export const variableWithValueSchema = z.object({
id: z.string(),
name: z.string(),
value: z.string(),
value: z.string().nullable(),
})

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/utils/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Variable,
InputBlock,
ResultHeaderCell,
ResultWithAnswers,
Answer,
VariableWithValue,
Typebot,
Expand Down Expand Up @@ -209,7 +208,7 @@ export const parseAnswers =
}
}
const variable = answerOrVariable as VariableWithValue
if (isDefined(o[variable.name])) return o
if (isDefined(o[variable.name]) || variable.value === null) return o
return { ...o, [variable.name]: variable.value }
}, {}),
}
Expand Down

4 comments on commit e6dceca

@vercel
Copy link

@vercel vercel bot commented on e6dceca Nov 22, 2022

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-alpha – ./apps/viewer

bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
cares.urlabout.me
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
1988.bouclidom.com
andreimayer.com.br
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
goalsettingbot.com
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.digitalbled.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.winglabs.com.br
carsalesenquiry.com
demo.botscientis.us
forms.webisharp.com
kbsub.wpwakanda.com
live.botscientis.us
mentoria.omelhor.vc
nutrisamirbayde.com
order.maitempah.com
quest.wpwakanda.com
test.botscientis.us
typebot.stillio.com
wordsandimagery.com
bium.gratirabbit.com
bot.ansuraniphone.my
bot.cotemeuplano.com
chat.hayurihijab.com
chatbee.agfunnel.com
click.sevenoways.com
connect.growthguy.in
kuiz.sistemniaga.com
offer.botscientis.us
sellmycarglasgow.com
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
abutton.wpwakanda.com
aidigitalmarketing.kr
bbutton.wpwakanda.com
onboarding.growthside.io
reward.onlinebotdemo.xyz
type.opaulovieira.com.br
aibot.angrybranding.co.uk
bot.aidigitalmarketing.kr
bot.arraesecenteno.com.br
bot.blackboxsports.com.br
bot.cabinrentalagency.com
boyfriend-breakup.riku.ai
brigadeirosemdrama.com.br
chat.ertcrebateportal.com
chat.thisiscrushhouse.com
sellmyharleylouisiana.com
verfica.botmachine.com.br
configurator.bouclidom.com
help.atlasoutfittersk9.com
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
piazzatorre.barrettamario.it
requests.swamprecordsgnv.com
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
yourfeedback.comebackreward.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
viewer-v2-alpha-typebot-io.vercel.app
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e6dceca Nov 22, 2022

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e6dceca Nov 22, 2022

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

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

@vercel
Copy link

@vercel vercel bot commented on e6dceca Nov 22, 2022

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.