import { Flex, HStack, Stack, Tag, Text } from '@chakra-ui/react' import { useTypebot } from 'contexts/TypebotContext' import { Step, StartStep, BubbleStepType, InputStepType, LogicStepType, SetVariableStep, ConditionStep, IntegrationStepType, } from 'models' import { ChoiceItemsList } from './ChoiceInputStepNode/ChoiceItemsList' import { SourceEndpoint } from './SourceEndpoint' type Props = { step: Step | StartStep isConnectable?: boolean } export const StepNodeContent = ({ step }: Props) => { switch (step.type) { case BubbleStepType.TEXT: { return ( Click to edit...

` : step.content.html, }} /> ) } case InputStepType.TEXT: { return ( {step.options?.labels?.placeholder ?? 'Type your answer...'} ) } case InputStepType.NUMBER: { return ( {step.options?.labels?.placeholder ?? 'Type your answer...'} ) } case InputStepType.EMAIL: { return ( {step.options?.labels?.placeholder ?? 'Type your email...'} ) } case InputStepType.URL: { return ( {step.options?.labels?.placeholder ?? 'Type your URL...'} ) } case InputStepType.DATE: { return ( {step.options?.labels?.from ?? 'Pick a date...'} ) } case InputStepType.PHONE: { return ( {step.options?.labels?.placeholder ?? 'Your phone number...'} ) } case InputStepType.CHOICE: { return } case LogicStepType.SET_VARIABLE: { return } case LogicStepType.CONDITION: { return } case IntegrationStepType.GOOGLE_SHEETS: { if (!step.options) return Configure... return {step.options?.action} } case 'start': { return {step.label} } default: { return No input } } } const SetVariableNodeContent = ({ step }: { step: SetVariableStep }) => { const { typebot } = useTypebot() const variableName = typebot?.variables.byId[step.options?.variableId ?? '']?.name ?? '' const expression = step.options?.expressionToEvaluate ?? '' return ( {variableName === '' && expression === '' ? 'Click to edit...' : `${variableName} = ${expression}`} ) } const ConditionNodeContent = ({ step }: { step: ConditionStep }) => { const { typebot } = useTypebot() return ( {step.options?.comparisons.allIds.map((comparisonId, idx) => { const comparison = step.options?.comparisons.byId[comparisonId] const variable = typebot?.variables.byId[comparison?.variableId ?? ''] return ( {idx > 0 && {step.options?.logicalOperator ?? ''}} {variable?.name && ( {variable.name} )} {comparison.comparisonOperator && ( {comparison?.comparisonOperator} )} {comparison?.value && ( {comparison.value} )} ) })} ) }