From 83ae57cf0c950159ccb5adeeb707bdb095afda61 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 21 Feb 2023 18:00:09 +0100 Subject: [PATCH] :bug: Fix variable buttons with new engine --- .../publish/components/embeds/snippetParsers/shared.ts | 2 +- .../inputs/buttons/api/utils/validateButtonInput.ts | 7 ++++++- packages/js/package.json | 2 +- .../inputs/fileUpload/components/FileUploadForm.tsx | 9 +++++++-- packages/react/package.json | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/builder/src/features/publish/components/embeds/snippetParsers/shared.ts b/apps/builder/src/features/publish/components/embeds/snippetParsers/shared.ts index e7d412c0a..e7adbacea 100644 --- a/apps/builder/src/features/publish/components/embeds/snippetParsers/shared.ts +++ b/apps/builder/src/features/publish/components/embeds/snippetParsers/shared.ts @@ -29,4 +29,4 @@ export const parseReactBotProps = ({ typebot, apiHost }: BotProps) => { return `${typebotLine} ${apiHostLine}` } -export const typebotImportUrl = `https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.9/dist/web.js` +export const typebotImportUrl = `https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0.10/dist/web.js` diff --git a/apps/viewer/src/features/blocks/inputs/buttons/api/utils/validateButtonInput.ts b/apps/viewer/src/features/blocks/inputs/buttons/api/utils/validateButtonInput.ts index c66e3e98c..f58c52c5b 100644 --- a/apps/viewer/src/features/blocks/inputs/buttons/api/utils/validateButtonInput.ts +++ b/apps/viewer/src/features/blocks/inputs/buttons/api/utils/validateButtonInput.ts @@ -3,4 +3,9 @@ import { ChoiceInputBlock } from 'models' export const validateButtonInput = ( buttonBlock: ChoiceInputBlock, input: string -) => buttonBlock.items.some((item) => item.content === input) +) => + buttonBlock.items.some( + (item) => + item.content === input || + (item.content?.startsWith('{{') && item.content.endsWith('}}')) + ) diff --git a/packages/js/package.json b/packages/js/package.json index 703c1d8ac..d5d138571 100644 --- a/packages/js/package.json +++ b/packages/js/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/js", - "version": "0.0.9", + "version": "0.0.10", "description": "Javascript library to display typebots on your website", "type": "module", "main": "dist/index.js", diff --git a/packages/js/src/features/blocks/inputs/fileUpload/components/FileUploadForm.tsx b/packages/js/src/features/blocks/inputs/fileUpload/components/FileUploadForm.tsx index 097117811..29cecdd67 100644 --- a/packages/js/src/features/blocks/inputs/fileUpload/components/FileUploadForm.tsx +++ b/packages/js/src/features/blocks/inputs/fileUpload/components/FileUploadForm.tsx @@ -1,5 +1,6 @@ import { SendButton, Spinner } from '@/components/SendButton' import { BotContext, InputSubmitContent } from '@/types' +import { guessApiHost } from '@/utils/guessApiHost' import { FileInputBlock } from 'models' import { defaultFileInputOptions } from 'models/features/blocks/inputs/file' import { createSignal, Match, Show, Switch } from 'solid-js' @@ -50,7 +51,9 @@ export const FileUploadForm = (props: Props) => { }) setIsUploading(true) const urls = await uploadFiles({ - basePath: `/api/typebots/${props.context.typebotId}/blocks/${props.block.id}`, + basePath: `${props.context.apiHost ?? guessApiHost()}/api/typebots/${ + props.context.typebotId + }/blocks/${props.block.id}`, files: [ { file, @@ -73,7 +76,9 @@ export const FileUploadForm = (props: Props) => { }) setIsUploading(true) const urls = await uploadFiles({ - basePath: `/api/typebots/${props.context.typebotId}/blocks/${props.block.id}`, + basePath: `${props.context.apiHost ?? guessApiHost()}/api/typebots/${ + props.context.typebotId + }/blocks/${props.block.id}`, files: files.map((file) => ({ file: file, path: `public/results/${props.context.resultId}/${props.block.id}/${file.name}`, diff --git a/packages/react/package.json b/packages/react/package.json index 5db596976..10ebc342d 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/react", - "version": "0.0.9", + "version": "0.0.10", "description": "React library to display typebots on your website", "main": "dist/index.js", "types": "dist/index.d.ts",