Skip to content

Commit

Permalink
🐛 (pictureChoice) Fix dynamic image only variable saving
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 19, 2024
1 parent f017219 commit 9c86c5e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PictureChoiceBlock, SessionState } from '@typebot.io/schemas'
import { ParsedReply } from '../../../types'
import { injectVariableValuesInPictureChoiceBlock } from './injectVariableValuesInPictureChoiceBlock'
import { isNotEmpty } from '@typebot.io/lib/utils'

export const parsePictureChoicesReply =
(state: SessionState) =>
Expand Down Expand Up @@ -64,7 +65,9 @@ export const parsePictureChoicesReply =
return {
status: 'success',
reply: matchedItems
.map((item) => item.title ?? item.pictureSrc ?? '')
.map((item) =>
isNotEmpty(item.title) ? item.title : item.pictureSrc ?? ''
)
.join(', '),
}
}
Expand All @@ -81,6 +84,8 @@ export const parsePictureChoicesReply =
if (!matchedItem) return { status: 'fail' }
return {
status: 'success',
reply: matchedItem.title ?? matchedItem.pictureSrc ?? '',
reply: isNotEmpty(matchedItem.title)
? matchedItem.title
: matchedItem.pictureSrc ?? '',
}
}
2 changes: 1 addition & 1 deletion packages/embeds/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.52",
"version": "0.2.53",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PictureChoiceBlock } from '@typebot.io/schemas/features/blocks/inputs/p
import { For, Show, createEffect, createSignal, onMount } from 'solid-js'
import { Checkbox } from '../buttons/components/Checkbox'
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 { isMobile } from '@/utils/isMobileSignal'
import { defaultPictureChoiceOptions } from '@typebot.io/schemas/features/blocks/inputs/pictureChoice/constants'
Expand Down Expand Up @@ -47,7 +47,7 @@ export const MultiplePictureChoice = (props: Props) => {
const item = props.defaultItems.find(
(item) => item.id === selectedItemId
)
return item?.title ?? item?.pictureSrc
return isNotEmpty(item?.title) ? item.title : item?.pictureSrc
})
.join(', '),
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SearchInput } from '@/components/inputs/SearchInput'
import { InputSubmitContent } from '@/types'
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 { For, Show, createEffect, createSignal, onMount } from 'solid-js'

Expand All @@ -24,7 +24,7 @@ export const SinglePictureChoice = (props: Props) => {
const handleClick = (itemIndex: number) => {
const item = filteredItems()[itemIndex]
return props.onSubmit({
label: item.title ?? item.pictureSrc ?? item.id,
label: isNotEmpty(item.title) ? item.title : item.pictureSrc ?? item.id,
value: item.id,
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.52",
"version": "0.2.53",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/embeds/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.52",
"version": "0.2.53",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 9c86c5e

Please sign in to comment.