2
0

♻️ (viewer) Remove barrel exports and flatten folder arch

This commit is contained in:
Baptiste Arnaud
2023-03-15 12:21:52 +01:00
parent 44d7a0bcb8
commit f3af07b7ff
113 changed files with 398 additions and 426 deletions

View File

@@ -0,0 +1,32 @@
import { ExecuteLogicResponse } from '@/features/chat/types'
import { parseVariables } from '@/features/variables/parseVariables'
import { SessionState, WaitBlock } from '@typebot.io/schemas'
export const executeWait = async (
{ typebot: { variables } }: SessionState,
block: WaitBlock,
lastBubbleBlockId?: string
): Promise<ExecuteLogicResponse> => {
if (!block.options.secondsToWaitFor)
return { outgoingEdgeId: block.outgoingEdgeId }
const parsedSecondsToWaitFor = safeParseInt(
parseVariables(variables)(block.options.secondsToWaitFor)
)
return {
outgoingEdgeId: block.outgoingEdgeId,
clientSideActions: parsedSecondsToWaitFor
? [
{
wait: { secondsToWaitFor: parsedSecondsToWaitFor },
lastBubbleBlockId,
},
]
: undefined,
}
}
const safeParseInt = (value: string) => {
const parsedValue = parseInt(value)
return isNaN(parsedValue) ? undefined : parsedValue
}