2
0

♻️ (bot) Change to features-centric folder structure

This commit is contained in:
Baptiste Arnaud
2022-11-15 14:59:34 +01:00
committed by Baptiste Arnaud
parent a5c8a8a95c
commit 972094425a
92 changed files with 1245 additions and 943 deletions

View 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)
}
}