🚸 (bot) Avoid waiting for blocks with no returned data
This commit is contained in:
@ -58,7 +58,7 @@ export const BlockNode = ({
|
||||
setFocusedGroupId,
|
||||
previewingEdge,
|
||||
} = useGraph()
|
||||
const { mouseOverBlock, setMouseOverBlock, draggedItem } = useBlockDnd()
|
||||
const { mouseOverBlock, setMouseOverBlock } = useBlockDnd()
|
||||
const { typebot, updateBlock } = useTypebot()
|
||||
const [isConnecting, setIsConnecting] = useState(false)
|
||||
const [isPopoverOpened, setIsPopoverOpened] = useState(
|
||||
@ -105,7 +105,7 @@ export const BlockNode = ({
|
||||
}
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
if (draggedItem !== undefined)
|
||||
if (mouseOverBlock?.id !== block.id)
|
||||
setMouseOverBlock({ id: block.id, ref: blockRef })
|
||||
if (connectingIds)
|
||||
setConnectingIds({
|
||||
|
@ -31,5 +31,5 @@
|
||||
"path": "node_modules/cz-emoji"
|
||||
}
|
||||
},
|
||||
"packageManager": "pnpm@7.14.0"
|
||||
"packageManager": "pnpm@7.16.1"
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ if (window.$chatwoot) {
|
||||
})(document, "script");
|
||||
}`
|
||||
|
||||
export const executeChatwootBlock = async (
|
||||
export const executeChatwootBlock = (
|
||||
block: ChatwootBlock,
|
||||
{ variables, isPreview, onNewLog }: IntegrationState
|
||||
) => {
|
||||
@ -74,7 +74,7 @@ export const executeChatwootBlock = async (
|
||||
)
|
||||
)
|
||||
try {
|
||||
await func(...variables.map((v) => parseCorrectValueType(v.value)))
|
||||
func(...variables.map((v) => parseCorrectValueType(v.value)))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ export const executeGoogleSheetBlock = async (
|
||||
if (!('action' in block.options)) return block.outgoingEdgeId
|
||||
switch (block.options.action) {
|
||||
case GoogleSheetsAction.INSERT_ROW:
|
||||
await insertRowInGoogleSheets(block.options, context)
|
||||
insertRowInGoogleSheets(block.options, context)
|
||||
break
|
||||
case GoogleSheetsAction.UPDATE_ROW:
|
||||
await updateRowInGoogleSheets(block.options, context)
|
||||
updateRowInGoogleSheets(block.options, context)
|
||||
break
|
||||
case GoogleSheetsAction.GET:
|
||||
await getRowFromGoogleSheets(block.options, context)
|
||||
@ -33,7 +33,7 @@ export const executeGoogleSheetBlock = async (
|
||||
return block.outgoingEdgeId
|
||||
}
|
||||
|
||||
const insertRowInGoogleSheets = async (
|
||||
const insertRowInGoogleSheets = (
|
||||
options: GoogleSheetsInsertRowOptions,
|
||||
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
||||
) => {
|
||||
@ -46,30 +46,31 @@ const insertRowInGoogleSheets = async (
|
||||
return
|
||||
}
|
||||
const params = stringify({ resultId })
|
||||
const { error } = await sendRequest({
|
||||
sendRequest({
|
||||
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
||||
method: 'POST',
|
||||
body: {
|
||||
credentialsId: options.credentialsId,
|
||||
values: parseCellValues(options.cellsToInsert, variables),
|
||||
},
|
||||
})
|
||||
onNewLog(
|
||||
parseLog(
|
||||
error,
|
||||
'Succesfully inserted a row in the sheet',
|
||||
'Failed to insert a row in the sheet'
|
||||
}).then(({ error }) => {
|
||||
onNewLog(
|
||||
parseLog(
|
||||
error,
|
||||
'Succesfully inserted a row in the sheet',
|
||||
'Failed to insert a row in the sheet'
|
||||
)
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const updateRowInGoogleSheets = async (
|
||||
const updateRowInGoogleSheets = (
|
||||
options: GoogleSheetsUpdateRowOptions,
|
||||
{ variables, apiHost, onNewLog, resultId }: IntegrationState
|
||||
) => {
|
||||
if (!options.cellsToUpsert || !options.referenceCell) return
|
||||
const params = stringify({ resultId })
|
||||
const { error } = await sendRequest({
|
||||
sendRequest({
|
||||
url: `${apiHost}/api/integrations/google-sheets/spreadsheets/${options.spreadsheetId}/sheets/${options.sheetId}?${params}`,
|
||||
method: 'PATCH',
|
||||
body: {
|
||||
@ -80,14 +81,15 @@ const updateRowInGoogleSheets = async (
|
||||
value: parseVariables(variables)(options.referenceCell.value ?? ''),
|
||||
},
|
||||
},
|
||||
})
|
||||
onNewLog(
|
||||
parseLog(
|
||||
error,
|
||||
'Succesfully updated a row in the sheet',
|
||||
'Failed to update a row in the sheet'
|
||||
}).then(({ error }) => {
|
||||
onNewLog(
|
||||
parseLog(
|
||||
error,
|
||||
'Succesfully updated a row in the sheet',
|
||||
'Failed to update a row in the sheet'
|
||||
)
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
const getRowFromGoogleSheets = async (
|
||||
|
@ -4,7 +4,7 @@ import { parseLog } from '@/utils/helpers'
|
||||
import { SendEmailBlock } from 'models'
|
||||
import { sendRequest, byId } from 'utils'
|
||||
|
||||
export const executeSendEmailBlock = async (
|
||||
export const executeSendEmailBlock = (
|
||||
block: SendEmailBlock,
|
||||
{
|
||||
variables,
|
||||
@ -25,7 +25,7 @@ export const executeSendEmailBlock = async (
|
||||
return block.outgoingEdgeId
|
||||
}
|
||||
const { options } = block
|
||||
const { error } = await sendRequest({
|
||||
sendRequest({
|
||||
url: `${apiHost}/api/typebots/${typebotId}/integrations/email?resultId=${resultId}`,
|
||||
method: 'POST',
|
||||
body: {
|
||||
@ -43,9 +43,11 @@ export const executeSendEmailBlock = async (
|
||||
isBodyCode: options.isBodyCode,
|
||||
resultValues,
|
||||
},
|
||||
}).then(({ error }) => {
|
||||
onNewLog(
|
||||
parseLog(error, 'Succesfully sent an email', 'Failed to send an email')
|
||||
)
|
||||
})
|
||||
onNewLog(
|
||||
parseLog(error, 'Succesfully sent an email', 'Failed to send an email')
|
||||
)
|
||||
|
||||
return block.outgoingEdgeId
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export const executeIntegration = ({
|
||||
}: {
|
||||
block: IntegrationBlock
|
||||
context: IntegrationState
|
||||
}): Promise<string | undefined> => {
|
||||
}): Promise<string | undefined> | string | undefined => {
|
||||
switch (block.type) {
|
||||
case IntegrationBlockType.GOOGLE_SHEETS:
|
||||
return executeGoogleSheetBlock(block, context)
|
||||
|
@ -25,6 +25,6 @@ export const executeLogic = async (
|
||||
case LogicBlockType.CODE:
|
||||
return { nextEdgeId: await executeCode(block, context) }
|
||||
case LogicBlockType.TYPEBOT_LINK:
|
||||
return await executeTypebotLink(block, context)
|
||||
return executeTypebotLink(block, context)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user