2
0

chore(viewer): 🛂 Dynamically parse the viewer api host

This commit is contained in:
Baptiste Arnaud
2022-02-10 14:31:44 +01:00
parent 0338acae82
commit cfbf3d4c0d
4 changed files with 61 additions and 45 deletions

View File

@ -31,7 +31,7 @@ export const ChatBlock = ({
onScroll,
onBlockEnd,
}: ChatBlockProps) => {
const { typebot, updateVariableValue, createEdge } = useTypebot()
const { typebot, updateVariableValue, createEdge, apiHost } = useTypebot()
const [displayedSteps, setDisplayedSteps] = useState<PublicStep[]>([])
const currentStepIndex = displayedSteps.length - 1
@ -60,13 +60,16 @@ export const ChatBlock = ({
nextEdgeId ? onBlockEnd(nextEdgeId) : displayNextStep()
}
if (isIntegrationStep(currentStep)) {
const nextEdgeId = await executeIntegration(
typebot.typebotId,
currentStep,
typebot.variables,
{ blockIndex, stepIndex: currentStepIndex },
updateVariableValue
)
const nextEdgeId = await executeIntegration({
step: currentStep,
context: {
apiHost,
typebotId: typebot.id,
indices: { blockIndex, stepIndex: currentStepIndex },
variables: typebot.variables,
updateVariableValue,
},
})
nextEdgeId ? onBlockEnd(nextEdgeId) : displayNextStep()
}
}