🐛 Fix default webhook body with multi inputs groups
This commit is contained in:
@ -261,9 +261,7 @@ const saveAnswer =
|
|||||||
? state.typebotsQueue[0].typebot.variables.find(
|
? state.typebotsQueue[0].typebot.variables.find(
|
||||||
(variable) => variable.id === block.options?.variableId
|
(variable) => variable.id === block.options?.variableId
|
||||||
)?.name
|
)?.name
|
||||||
: state.typebotsQueue[0].typebot.groups.find((group) =>
|
: parseGroupKey(block.id, { state })
|
||||||
group.blocks.find((blockInGroup) => blockInGroup.id === block.id)
|
|
||||||
)?.title
|
|
||||||
|
|
||||||
return setNewAnswerInState(state)({
|
return setNewAnswerInState(state)({
|
||||||
key: key ?? block.id,
|
key: key ?? block.id,
|
||||||
@ -271,6 +269,21 @@ const saveAnswer =
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const parseGroupKey = (blockId: string, { state }: { state: SessionState }) => {
|
||||||
|
const group = state.typebotsQueue[0].typebot.groups.find((group) =>
|
||||||
|
group.blocks.find((b) => b.id === blockId)
|
||||||
|
)
|
||||||
|
if (!group) return
|
||||||
|
|
||||||
|
const inputBlockNumber = group.blocks
|
||||||
|
.filter(isInputBlock)
|
||||||
|
.findIndex((b) => b.id === blockId)
|
||||||
|
|
||||||
|
return inputBlockNumber > 0
|
||||||
|
? `${group.title} (${inputBlockNumber})`
|
||||||
|
: group?.title
|
||||||
|
}
|
||||||
|
|
||||||
const setNewAnswerInState =
|
const setNewAnswerInState =
|
||||||
(state: SessionState) => (newAnswer: AnswerInSessionState) => {
|
(state: SessionState) => (newAnswer: AnswerInSessionState) => {
|
||||||
const answers = state.typebotsQueue[0].answers
|
const answers = state.typebotsQueue[0].answers
|
||||||
|
Reference in New Issue
Block a user