feat(engine): ✨ Add {{state}} to body to get form state
This commit is contained in:
@ -16,6 +16,7 @@ import { executeLogic } from 'services/logic'
|
||||
import { executeIntegration } from 'services/integration'
|
||||
import { parseRetryStep, stepCanBeRetried } from 'services/inputs'
|
||||
import { parseVariables } from 'index'
|
||||
import { useAnswers } from 'contexts/AnswersContext'
|
||||
|
||||
type ChatBlockProps = {
|
||||
steps: PublicStep[]
|
||||
@ -32,6 +33,7 @@ export const ChatBlock = ({
|
||||
}: ChatBlockProps) => {
|
||||
const { typebot, updateVariableValue, createEdge, apiHost, isPreview } =
|
||||
useTypebot()
|
||||
const { resultValues } = useAnswers()
|
||||
const [displayedSteps, setDisplayedSteps] = useState<PublicStep[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
@ -68,6 +70,8 @@ export const ChatBlock = ({
|
||||
variables: typebot.variables,
|
||||
isPreview,
|
||||
updateVariableValue,
|
||||
resultValues,
|
||||
blocks: typebot.blocks,
|
||||
},
|
||||
})
|
||||
nextEdgeId ? onBlockEnd(nextEdgeId) : displayNextStep()
|
||||
|
@ -30,7 +30,10 @@ export const ConversationContainer = ({
|
||||
{ block: PublicBlock; startStepIndex: number }[]
|
||||
>([])
|
||||
const [localAnswer, setLocalAnswer] = useState<Answer | undefined>()
|
||||
const { answers } = useAnswers()
|
||||
const {
|
||||
resultValues: { answers },
|
||||
setPrefilledVariables,
|
||||
} = useAnswers()
|
||||
const bottomAnchor = useRef<HTMLDivElement | null>(null)
|
||||
const scrollableContainer = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
@ -51,7 +54,10 @@ export const ConversationContainer = ({
|
||||
|
||||
useEffect(() => {
|
||||
const prefilledVariables = injectUrlParamsIntoVariables()
|
||||
if (onVariablesPrefilled) onVariablesPrefilled(prefilledVariables)
|
||||
if (onVariablesPrefilled) {
|
||||
onVariablesPrefilled(prefilledVariables)
|
||||
setPrefilledVariables(prefilledVariables)
|
||||
}
|
||||
displayNextBlock(typebot.blocks[0].steps[0].outgoingEdgeId)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
Reference in New Issue
Block a user