♻️ (bot) Change to features-centric folder structure
This commit is contained in:
committed by
Baptiste Arnaud
parent
a5c8a8a95c
commit
972094425a
30
packages/bot-engine/src/utils/executeLogic.ts
Normal file
30
packages/bot-engine/src/utils/executeLogic.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { TypebotViewerProps } from '@/components/TypebotViewer'
|
||||
import { executeCode } from '@/features/blocks/logic/code'
|
||||
import { executeCondition } from '@/features/blocks/logic/condition'
|
||||
import { executeRedirect } from '@/features/blocks/logic/redirect'
|
||||
import { executeSetVariable } from '@/features/blocks/logic/setVariable'
|
||||
import { executeTypebotLink } from '@/features/blocks/logic/typebotLink'
|
||||
import { LinkedTypebot } from '@/providers/TypebotProvider'
|
||||
import { EdgeId, LogicState } from '@/types'
|
||||
import { LogicBlock, LogicBlockType } from 'models'
|
||||
|
||||
export const executeLogic = async (
|
||||
block: LogicBlock,
|
||||
context: LogicState
|
||||
): Promise<{
|
||||
nextEdgeId?: EdgeId
|
||||
linkedTypebot?: TypebotViewerProps['typebot'] | LinkedTypebot
|
||||
}> => {
|
||||
switch (block.type) {
|
||||
case LogicBlockType.SET_VARIABLE:
|
||||
return { nextEdgeId: executeSetVariable(block, context) }
|
||||
case LogicBlockType.CONDITION:
|
||||
return { nextEdgeId: executeCondition(block, context) }
|
||||
case LogicBlockType.REDIRECT:
|
||||
return { nextEdgeId: executeRedirect(block, context) }
|
||||
case LogicBlockType.CODE:
|
||||
return { nextEdgeId: await executeCode(block, context) }
|
||||
case LogicBlockType.TYPEBOT_LINK:
|
||||
return await executeTypebotLink(block, context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user