2
0

feat(engine): Add {{state}} to body to get form state

This commit is contained in:
Baptiste Arnaud
2022-02-22 06:55:15 +01:00
parent 1b900b3f5d
commit d0994e6577
8 changed files with 89 additions and 19 deletions

View File

@ -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
}, [])