🐛 (pictureChoice) Fix dynamic image only variable saving
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { PictureChoiceBlock, SessionState } from '@typebot.io/schemas'
|
import { PictureChoiceBlock, SessionState } from '@typebot.io/schemas'
|
||||||
import { ParsedReply } from '../../../types'
|
import { ParsedReply } from '../../../types'
|
||||||
import { injectVariableValuesInPictureChoiceBlock } from './injectVariableValuesInPictureChoiceBlock'
|
import { injectVariableValuesInPictureChoiceBlock } from './injectVariableValuesInPictureChoiceBlock'
|
||||||
|
import { isNotEmpty } from '@typebot.io/lib/utils'
|
||||||
|
|
||||||
export const parsePictureChoicesReply =
|
export const parsePictureChoicesReply =
|
||||||
(state: SessionState) =>
|
(state: SessionState) =>
|
||||||
@@ -64,7 +65,9 @@ export const parsePictureChoicesReply =
|
|||||||
return {
|
return {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
reply: matchedItems
|
reply: matchedItems
|
||||||
.map((item) => item.title ?? item.pictureSrc ?? '')
|
.map((item) =>
|
||||||
|
isNotEmpty(item.title) ? item.title : item.pictureSrc ?? ''
|
||||||
|
)
|
||||||
.join(', '),
|
.join(', '),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,6 +84,8 @@ export const parsePictureChoicesReply =
|
|||||||
if (!matchedItem) return { status: 'fail' }
|
if (!matchedItem) return { status: 'fail' }
|
||||||
return {
|
return {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
reply: matchedItem.title ?? matchedItem.pictureSrc ?? '',
|
reply: isNotEmpty(matchedItem.title)
|
||||||
|
? matchedItem.title
|
||||||
|
: matchedItem.pictureSrc ?? '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.52",
|
"version": "0.2.53",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { PictureChoiceBlock } from '@typebot.io/schemas/features/blocks/inputs/p
|
|||||||
import { For, Show, createEffect, createSignal, onMount } from 'solid-js'
|
import { For, Show, createEffect, createSignal, onMount } from 'solid-js'
|
||||||
import { Checkbox } from '../buttons/components/Checkbox'
|
import { Checkbox } from '../buttons/components/Checkbox'
|
||||||
import { SendButton } from '@/components'
|
import { SendButton } from '@/components'
|
||||||
import { isDefined, isEmpty, isSvgSrc } from '@typebot.io/lib'
|
import { isDefined, isEmpty, isNotEmpty, isSvgSrc } from '@typebot.io/lib'
|
||||||
import { SearchInput } from '@/components/inputs/SearchInput'
|
import { SearchInput } from '@/components/inputs/SearchInput'
|
||||||
import { isMobile } from '@/utils/isMobileSignal'
|
import { isMobile } from '@/utils/isMobileSignal'
|
||||||
import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants'
|
import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants'
|
||||||
@@ -47,7 +47,7 @@ export const MultiplePictureChoice = (props: Props) => {
|
|||||||
const item = props.defaultItems.find(
|
const item = props.defaultItems.find(
|
||||||
(item) => item.id === selectedItemId
|
(item) => item.id === selectedItemId
|
||||||
)
|
)
|
||||||
return item?.title ?? item?.pictureSrc
|
return isNotEmpty(item?.title) ? item.title : item?.pictureSrc
|
||||||
})
|
})
|
||||||
.join(', '),
|
.join(', '),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { SearchInput } from '@/components/inputs/SearchInput'
|
import { SearchInput } from '@/components/inputs/SearchInput'
|
||||||
import { InputSubmitContent } from '@/types'
|
import { InputSubmitContent } from '@/types'
|
||||||
import { isMobile } from '@/utils/isMobileSignal'
|
import { isMobile } from '@/utils/isMobileSignal'
|
||||||
import { isDefined, isSvgSrc } from '@typebot.io/lib/utils'
|
import { isDefined, isNotEmpty, isSvgSrc } from '@typebot.io/lib/utils'
|
||||||
import { PictureChoiceBlock } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice'
|
import { PictureChoiceBlock } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice'
|
||||||
import { For, Show, createEffect, createSignal, onMount } from 'solid-js'
|
import { For, Show, createEffect, createSignal, onMount } from 'solid-js'
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ export const SinglePictureChoice = (props: Props) => {
|
|||||||
const handleClick = (itemIndex: number) => {
|
const handleClick = (itemIndex: number) => {
|
||||||
const item = filteredItems()[itemIndex]
|
const item = filteredItems()[itemIndex]
|
||||||
return props.onSubmit({
|
return props.onSubmit({
|
||||||
label: item.title ?? item.pictureSrc ?? item.id,
|
label: isNotEmpty(item.title) ? item.title : item.pictureSrc ?? item.id,
|
||||||
value: item.id,
|
value: item.id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.52",
|
"version": "0.2.53",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.52",
|
"version": "0.2.53",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user