🚸 Display error toast when script or set vari…
This commit is contained in:
@@ -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': {
|
||||
|
||||
Reference in New Issue
Block a user