@ -0,0 +1,22 @@
|
||||
import { ExecuteLogicResponse } from '@/features/chat'
|
||||
import { parseVariables } from '@/features/variables'
|
||||
import { SessionState, WaitBlock } from 'models'
|
||||
|
||||
export const executeWait = async (
|
||||
{ typebot: { variables } }: SessionState,
|
||||
block: WaitBlock
|
||||
): Promise<ExecuteLogicResponse> => {
|
||||
if (!block.options.secondsToWaitFor)
|
||||
return { outgoingEdgeId: block.outgoingEdgeId }
|
||||
const parsedSecondsToWaitFor = parseVariables(variables)(
|
||||
block.options.secondsToWaitFor
|
||||
)
|
||||
|
||||
return {
|
||||
outgoingEdgeId: block.outgoingEdgeId,
|
||||
// @ts-expect-error isNaN can be used with strings
|
||||
clientSideActions: isNaN(parsedSecondsToWaitFor)
|
||||
? undefined
|
||||
: [{ wait: { secondsToWaitFor: parsedSecondsToWaitFor } }],
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ import { executeCondition } from '@/features/blocks/logic/condition/api'
|
||||
import { executeRedirect } from '@/features/blocks/logic/redirect/api'
|
||||
import { executeSetVariable } from '@/features/blocks/logic/setVariable/api'
|
||||
import { executeTypebotLink } from '@/features/blocks/logic/typebotLink/api'
|
||||
import { executeWait } from '@/features/blocks/logic/wait/api/utils/executeWait'
|
||||
import { LogicBlock, LogicBlockType, SessionState } from 'models'
|
||||
import { ExecuteLogicResponse } from '../../types'
|
||||
|
||||
@ -20,5 +21,7 @@ export const executeLogic =
|
||||
return executeCode(state, block)
|
||||
case LogicBlockType.TYPEBOT_LINK:
|
||||
return executeTypebotLink(state, block)
|
||||
case LogicBlockType.WAIT:
|
||||
return executeWait(state, block)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user