diff --git a/apps/builder/components/shared/Graph/Nodes/BlockNode/BlockNodeContent/contents/RatingInputContent.tsx b/apps/builder/components/shared/Graph/Nodes/BlockNode/BlockNodeContent/contents/RatingInputContent.tsx index 7e2859369..7f4384a8a 100644 --- a/apps/builder/components/shared/Graph/Nodes/BlockNode/BlockNodeContent/contents/RatingInputContent.tsx +++ b/apps/builder/components/shared/Graph/Nodes/BlockNode/BlockNodeContent/contents/RatingInputContent.tsx @@ -7,6 +7,7 @@ type Props = { export const RatingInputContent = ({ block }: Props) => ( - Rate from 1 to {block.options.length} + Rate from {block.options.buttonType === 'Icons' ? 1 : 0} to{' '} + {block.options.length} ) diff --git a/apps/builder/components/shared/Graph/Nodes/BlockNode/SettingsPopoverContent/bodies/RatingInputSettingsBody.tsx b/apps/builder/components/shared/Graph/Nodes/BlockNode/SettingsPopoverContent/bodies/RatingInputSettingsBody.tsx index 0250ff950..2a556c315 100644 --- a/apps/builder/components/shared/Graph/Nodes/BlockNode/SettingsPopoverContent/bodies/RatingInputSettingsBody.tsx +++ b/apps/builder/components/shared/Graph/Nodes/BlockNode/SettingsPopoverContent/bodies/RatingInputSettingsBody.tsx @@ -33,9 +33,6 @@ export const RatingInputSettings = ({ const handleLeftLabelChange = (left: string) => onOptionsChange({ ...options, labels: { ...options.labels, left } }) - const handleMiddleLabelChange = (middle: string) => - onOptionsChange({ ...options, labels: { ...options.labels, middle } }) - const handleRightLabelChange = (right: string) => onOptionsChange({ ...options, labels: { ...options.labels, right } }) @@ -92,7 +89,7 @@ export const RatingInputSettings = ({ )} - 1 label: + {options.buttonType === 'Icons' ? '1' : '0'} label: - {options.length >= 4 && ( - - - {Math.floor(options.length / 2)} label: - - - - )} {options.length} label: diff --git a/apps/builder/playwright/tests/inputs/rating.spec.ts b/apps/builder/playwright/tests/inputs/rating.spec.ts index 22d1306c6..0c6f50e52 100644 --- a/apps/builder/playwright/tests/inputs/rating.spec.ts +++ b/apps/builder/playwright/tests/inputs/rating.spec.ts @@ -39,15 +39,14 @@ test('options should work', async ({ page }) => { await typebotViewer(page).locator(`text=8`).click() await typebotViewer(page).locator(`text=Send`).click() await expect(typebotViewer(page).locator(`text=8`)).toBeVisible() - await page.click('text=Rate from 1 to 10') - await page.click('text=10') - await page.click('text=5') + await page.click('text=Rate from 0 to 10') + await page.click('text="10"') + await page.click('text="5"') await page.click('text=Numbers') await page.click('text=Icons') await page.click('text="Custom icon?"') await page.fill('[placeholder="..."]', boxSvg) await page.fill('[placeholder="Not likely at all"]', 'Not likely at all') - await page.fill('[placeholder="Neutral"]', 'Neutral') await page.fill('[placeholder="Extremely likely"]', 'Extremely likely') await page.click('text="Restart"') await expect(typebotViewer(page).locator(`text=8`)).toBeHidden() @@ -55,7 +54,6 @@ test('options should work', async ({ page }) => { await expect( typebotViewer(page).locator(`text=Not likely at all`) ).toBeVisible() - await expect(typebotViewer(page).locator(`text=Neutral`)).toBeVisible() await expect( typebotViewer(page).locator(`text=Extremely likely`) ).toBeVisible() diff --git a/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/RatingForm.tsx b/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/RatingForm.tsx index 7d0afacbf..89c459a9b 100644 --- a/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/RatingForm.tsx +++ b/packages/bot-engine/src/components/ChatGroup/ChatBlock/inputs/RatingForm.tsx @@ -1,5 +1,5 @@ import { RatingInputOptions, RatingInputBlock } from 'models' -import React, { FormEvent, useRef, useState } from 'react' +import React, { FormEvent, useState } from 'react' import { isDefined, isEmpty, isNotDefined } from 'utils' import { InputSubmitContent } from '../InputChatBlock' import { SendButton } from './SendButton' @@ -11,7 +11,6 @@ type Props = { export const RatingForm = ({ block, onSubmit }: Props) => { const [rating, setRating] = useState() - const scaleElement = useRef(null) const handleSubmit = (e: FormEvent) => { e.preventDefault() @@ -23,33 +22,32 @@ export const RatingForm = ({ block, onSubmit }: Props) => { return (
-
-
- {Array.from(Array(block.options.length)).map((_, idx) => ( - - ))} -
- -
- {{block.options.labels.left}} - {!isEmpty(block.options.labels.middle) && ( - - {block.options.labels.middle} - - )} - { - - {block.options.labels.right} - - } -
+ {block.options.labels.left && ( + + {block.options.labels.left} + + )} +
+ {Array.from( + Array( + block.options.length + + (block.options.buttonType === 'Numbers' ? 1 : 0) + ) + ).map((_, idx) => ( + + ))}
+ {block.options.labels.right && ( + + {block.options.labels.right} + + )}
{isDefined(rating) && ( diff --git a/packages/models/src/typebot/blocks/input/rating.ts b/packages/models/src/typebot/blocks/input/rating.ts index 2a35c8c54..f1e6130e1 100644 --- a/packages/models/src/typebot/blocks/input/rating.ts +++ b/packages/models/src/typebot/blocks/input/rating.ts @@ -20,7 +20,6 @@ export const ratingInputOptionsSchema = optionBaseSchema.and( labels: z.object({ left: z.string().optional(), right: z.string().optional(), - middle: z.string().optional(), button: z.string(), }), customIcon: z.object({