Skip to content

Commit

Permalink
✨ (rating) Add one click submit option
Browse files Browse the repository at this point in the history
Closes #187
  • Loading branch information
baptisteArno committed Dec 24, 2022
1 parent 2934af8 commit 449080b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const RatingInputSettings = ({
const handleVariableChange = (variable?: Variable) =>
onOptionsChange({ ...options, variableId: variable?.id })

const handleOneClickSubmitChange = (isOneClickSubmitEnabled: boolean) =>
onOptionsChange({ ...options, isOneClickSubmitEnabled })

return (
<Stack spacing={4}>
<Stack>
Expand Down Expand Up @@ -108,6 +111,12 @@ export const RatingInputSettings = ({
placeholder="Extremely likely"
/>
</Stack>
<SwitchWithLabel
label="One click submit"
moreInfoContent='If enabled, the answer will be submitted as soon as the user clicks on a rating instead of showing the "Send" button.'
initialValue={options.isOneClickSubmitEnabled ?? false}
onCheckChange={handleOneClickSubmitChange}
/>
<Stack>
<FormLabel mb="0" htmlFor="button">
Button label:
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/blocks/inputs/rating/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { RatingInputSettings } from './components/RatingInputSettingsBody'
export { RatingInputSettings } from './components/RatingInputSettings'
export { RatingInputContent } from './components/RatingInputContent'
export { RatingInputIcon } from './components/RatingInputIcon'
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test('options should work', async ({ page }) => {
await page.click('text=Rate from 0 to 10')
await page.click('text="10"')
await page.click('text="5"')
await page.getByText('One click submit').click()
await page.click('text=Numbers')
await page.click('text=Icons')
await page.click('text="Custom icon?"')
Expand All @@ -56,6 +57,5 @@ test('options should work', async ({ page }) => {
typebotViewer(page).locator(`text=Extremely likely`)
).toBeVisible()
await typebotViewer(page).locator(`svg >> nth=4`).click()
await typebotViewer(page).locator(`text=Send`).click()
await expect(typebotViewer(page).locator(`text=5`)).toBeVisible()
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const RatingForm = ({ block, onSubmit }: Props) => {
onSubmit({ value: rating.toString() })
}

const handleClick = (rating: number) => setRating(rating)
const handleClick = (rating: number) => {
if (block.options.isOneClickSubmitEnabled)
onSubmit({ value: rating.toString() })
setRating(rating)
}

return (
<form className="flex flex-col" onSubmit={handleSubmit}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const RatingForm = (props: Props) => {
props.onSubmit({ value: rating.toString() })
}

const handleClick = (rating: number) => setRating(rating)
const handleClick = (rating: number) => {
if (props.block.options.isOneClickSubmitEnabled)
props.onSubmit({ value: rating.toString() })
setRating(rating)
}

return (
<form class="flex flex-col" onSubmit={handleSubmit}>
Expand Down
1 change: 1 addition & 0 deletions packages/models/src/features/blocks/inputs/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const ratingInputOptionsSchema = optionBaseSchema.and(
isEnabled: z.boolean(),
svg: z.string().optional(),
}),
isOneClickSubmitEnabled: z.boolean().optional(),
})
)

Expand Down

5 comments on commit 449080b

@vercel
Copy link

@vercel vercel bot commented on 449080b Dec 24, 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 449080b Dec 24, 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:

docs – ./apps/docs

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

@vercel
Copy link

@vercel vercel bot commented on 449080b Dec 24, 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 449080b Dec 24, 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

pant.maxbot.com.br
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
chatbot.repplai.com
demo.botscientis.us
forms.webisharp.com
kbsub.wpwakanda.com
live.botscientis.us
mentoria.omelhor.vc
bot.truongnguyen.live
cdd.searchcube.com.sg
chat.missarkansas.org
chatbot.ownacademy.co
sbutton.wpwakanda.com
815639944.21000000.one
aplicacao.bmind.com.br
apply.ansuraniphone.my
bbutton.wpwwakanda.com
bot.louismarcondes.com
bot.t20worldcup.com.au
c23111azqw.nigerias.io
felipewelington.com.br
form.searchcube.com.sg
gcase.barrettamario.it
help.giversforgood.com
info.clickasuransi.com
kodawariab736.skeep.it
my.swamprecordsgnv.com
premium.kandabrand.com
report.gratirabbit.com
resume.gratirabbit.com
83242573.actualizar.xyz
bot.blackboxtips.com.br
bot.upgradesolutions.eu
help.comebackreward.com
mainmenu.diddancing.com
register.kandabrand.com
signup.hypemarketing.in
subfooter.wpwakanda.com
survey.hypemarketing.in
testbot.afterorigin.com
91181264.your-access.one
ai.chromebookstoreph.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
link.cascadigital.com.br
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
bot.fusionstarreviews.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
elevateyourmind.groovepages.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 449080b Dec 24, 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

Please sign in to comment.