✨ Add conditional choice items
Allows you to conditonnally display an item from the Buttons or the Picture choice input Closes #546
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { ConditionBlock, SessionState } from '@typebot.io/schemas'
|
||||
import { ExecuteLogicResponse } from '@/features/chat/types'
|
||||
import { executeCondition } from './executeCondition'
|
||||
|
||||
export const executeConditionBlock = (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
block: ConditionBlock
|
||||
): ExecuteLogicResponse => {
|
||||
const passedCondition = block.items.find((item) =>
|
||||
executeCondition(variables)(item.content)
|
||||
)
|
||||
return {
|
||||
outgoingEdgeId: passedCondition
|
||||
? passedCondition.outgoingEdgeId
|
||||
: block.outgoingEdgeId,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user