🚸 Display error toast when script or set vari…

This commit is contained in:
Baptiste Arnaud
2024-06-11 18:18:05 +02:00
parent d80b3eaddb
commit 233ff91a57
15 changed files with 151 additions and 50 deletions

View File

@@ -15,6 +15,7 @@ import { TextInput, Textarea } from '@/components/inputs'
import { isDefined } from '@typebot.io/lib'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { isInputBlock } from '@typebot.io/schemas/helpers'
import { RadioButtons } from '@/components/inputs/RadioButtons'
type Props = {
options: SetVariableBlock['options']
@@ -172,6 +173,14 @@ const SetVariableValue = ({
})
}
const updateIsCode = (radio: 'Text' | 'Code') => {
if (options?.type && options.type !== 'Custom') return
onOptionsChange({
...options,
isCode: radio === 'Code',
})
}
switch (options?.type) {
case 'Custom':
case undefined:
@@ -186,11 +195,31 @@ const SetVariableValue = ({
}
onCheckChange={updateClientExecution}
/>
<CodeEditor
defaultValue={options?.expressionToEvaluate ?? ''}
onChange={updateExpression}
lang="javascript"
/>
<Stack>
<RadioButtons
size="sm"
options={['Text', 'Code']}
defaultValue={
options?.isCode ?? defaultSetVariableOptions.isCode
? 'Code'
: 'Text'
}
onSelect={updateIsCode}
/>
{options?.isCode === undefined || options.isCode ? (
<CodeEditor
defaultValue={options?.expressionToEvaluate ?? ''}
onChange={updateExpression}
lang="javascript"
/>
) : (
<Textarea
defaultValue={options?.expressionToEvaluate ?? ''}
onChange={updateExpression}
width="full"
/>
)}
</Stack>
</>
)
case 'Map item with same index': {