2
0

fix(engine): 🐛 Save variables from webhooks in results

This commit is contained in:
Baptiste Arnaud
2022-03-28 17:07:47 +02:00
parent cd6c5c04c5
commit 60dcd5c246
12 changed files with 98 additions and 56 deletions

View File

@ -14,21 +14,19 @@ type Props = {
predefinedVariables?: { [key: string]: string | undefined }
onNewBlockVisible: (edge: Edge) => void
onCompleted: () => void
onVariablesPrefilled?: (prefilledVariables: VariableWithValue[]) => void
}
export const ConversationContainer = ({
theme,
predefinedVariables,
onNewBlockVisible,
onCompleted,
onVariablesPrefilled,
}: Props) => {
const { typebot, updateVariableValue } = useTypebot()
const { document: frameDocument } = useFrame()
const [displayedBlocks, setDisplayedBlocks] = useState<
{ block: Block; startStepIndex: number }[]
>([])
const { setPrefilledVariables } = useAnswers()
const { updateVariables } = useAnswers()
const bottomAnchor = useRef<HTMLDivElement | null>(null)
const scrollableContainer = useRef<HTMLDivElement | null>(null)
@ -53,8 +51,7 @@ export const ConversationContainer = ({
useEffect(() => {
const prefilledVariables = injectPredefinedVariables(predefinedVariables)
if (onVariablesPrefilled) onVariablesPrefilled(prefilledVariables)
setPrefilledVariables(prefilledVariables)
updateVariables(prefilledVariables)
displayNextBlock(typebot.blocks[0].steps[0].outgoingEdgeId)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])