@@ -42,6 +42,9 @@ export const RatingInputSettings = ({
|
|||||||
const handleVariableChange = (variable?: Variable) =>
|
const handleVariableChange = (variable?: Variable) =>
|
||||||
onOptionsChange({ ...options, variableId: variable?.id })
|
onOptionsChange({ ...options, variableId: variable?.id })
|
||||||
|
|
||||||
|
const handleOneClickSubmitChange = (isOneClickSubmitEnabled: boolean) =>
|
||||||
|
onOptionsChange({ ...options, isOneClickSubmitEnabled })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -108,6 +111,12 @@ export const RatingInputSettings = ({
|
|||||||
placeholder="Extremely likely"
|
placeholder="Extremely likely"
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</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>
|
<Stack>
|
||||||
<FormLabel mb="0" htmlFor="button">
|
<FormLabel mb="0" htmlFor="button">
|
||||||
Button label:
|
Button label:
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
export { RatingInputSettings } from './components/RatingInputSettingsBody'
|
export { RatingInputSettings } from './components/RatingInputSettings'
|
||||||
export { RatingInputContent } from './components/RatingInputContent'
|
export { RatingInputContent } from './components/RatingInputContent'
|
||||||
export { RatingInputIcon } from './components/RatingInputIcon'
|
export { RatingInputIcon } from './components/RatingInputIcon'
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ test('options should work', async ({ page }) => {
|
|||||||
await page.click('text=Rate from 0 to 10')
|
await page.click('text=Rate from 0 to 10')
|
||||||
await page.click('text="10"')
|
await page.click('text="10"')
|
||||||
await page.click('text="5"')
|
await page.click('text="5"')
|
||||||
|
await page.getByText('One click submit').click()
|
||||||
await page.click('text=Numbers')
|
await page.click('text=Numbers')
|
||||||
await page.click('text=Icons')
|
await page.click('text=Icons')
|
||||||
await page.click('text="Custom icon?"')
|
await page.click('text="Custom icon?"')
|
||||||
@@ -56,6 +57,5 @@ test('options should work', async ({ page }) => {
|
|||||||
typebotViewer(page).locator(`text=Extremely likely`)
|
typebotViewer(page).locator(`text=Extremely likely`)
|
||||||
).toBeVisible()
|
).toBeVisible()
|
||||||
await typebotViewer(page).locator(`svg >> nth=4`).click()
|
await typebotViewer(page).locator(`svg >> nth=4`).click()
|
||||||
await typebotViewer(page).locator(`text=Send`).click()
|
|
||||||
await expect(typebotViewer(page).locator(`text=5`)).toBeVisible()
|
await expect(typebotViewer(page).locator(`text=5`)).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ export const RatingForm = ({ block, onSubmit }: Props) => {
|
|||||||
onSubmit({ value: rating.toString() })
|
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 (
|
return (
|
||||||
<form className="flex flex-col" onSubmit={handleSubmit}>
|
<form className="flex flex-col" onSubmit={handleSubmit}>
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ export const RatingForm = (props: Props) => {
|
|||||||
props.onSubmit({ value: rating.toString() })
|
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 (
|
return (
|
||||||
<form class="flex flex-col" onSubmit={handleSubmit}>
|
<form class="flex flex-col" onSubmit={handleSubmit}>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const ratingInputOptionsSchema = optionBaseSchema.and(
|
|||||||
isEnabled: z.boolean(),
|
isEnabled: z.boolean(),
|
||||||
svg: z.string().optional(),
|
svg: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
|
isOneClickSubmitEnabled: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user