feat(editor): ✨ Restore published version button
Had to migrate webhooks into a standalone table
This commit is contained in:
@ -3,7 +3,6 @@ import { TransitionGroup, CSSTransition } from 'react-transition-group'
|
||||
import { ChatStep } from './ChatStep'
|
||||
import { AvatarSideContainer } from './AvatarSideContainer'
|
||||
import { HostAvatarsContext } from '../../contexts/HostAvatarsContext'
|
||||
import { PublicStep } from 'models'
|
||||
import { useTypebot } from '../../contexts/TypebotContext'
|
||||
import {
|
||||
isBubbleStep,
|
||||
@ -17,9 +16,10 @@ import { executeIntegration } from 'services/integration'
|
||||
import { parseRetryStep, stepCanBeRetried } from 'services/inputs'
|
||||
import { parseVariables } from 'index'
|
||||
import { useAnswers } from 'contexts/AnswersContext'
|
||||
import { Step } from 'models'
|
||||
|
||||
type ChatBlockProps = {
|
||||
steps: PublicStep[]
|
||||
steps: Step[]
|
||||
startStepIndex: number
|
||||
onScroll: () => void
|
||||
onBlockEnd: (edgeId?: string) => void
|
||||
@ -34,7 +34,7 @@ export const ChatBlock = ({
|
||||
const { typebot, updateVariableValue, createEdge, apiHost, isPreview } =
|
||||
useTypebot()
|
||||
const { resultValues } = useAnswers()
|
||||
const [displayedSteps, setDisplayedSteps] = useState<PublicStep[]>([])
|
||||
const [displayedSteps, setDisplayedSteps] = useState<Step[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
const nextStep = steps[startStepIndex]
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useAnswers } from '../../../contexts/AnswersContext'
|
||||
import { useHostAvatars } from '../../../contexts/HostAvatarsContext'
|
||||
import { InputStep, InputStepType, PublicStep } from 'models'
|
||||
import { InputStep, InputStepType, Step } from 'models'
|
||||
import { GuestBubble } from './bubbles/GuestBubble'
|
||||
import { TextForm } from './inputs/TextForm'
|
||||
import { byId, isBubbleStep, isInputStep } from 'utils'
|
||||
@ -16,7 +16,7 @@ export const ChatStep = ({
|
||||
step,
|
||||
onTransitionEnd,
|
||||
}: {
|
||||
step: PublicStep
|
||||
step: Step
|
||||
onTransitionEnd: (answerContent?: string, isRetry?: boolean) => void
|
||||
}) => {
|
||||
const { addAnswer } = useAnswers()
|
||||
|
@ -5,7 +5,7 @@ import { useFrame } from 'react-frame-component'
|
||||
import { setCssVariablesValue } from '../services/theme'
|
||||
import { useAnswers } from '../contexts/AnswersContext'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { Answer, Edge, PublicBlock, Theme, VariableWithValue } from 'models'
|
||||
import { Answer, Block, Edge, Theme, VariableWithValue } from 'models'
|
||||
import { byId, isNotDefined } from 'utils'
|
||||
import { animateScroll as scroll } from 'react-scroll'
|
||||
import { useTypebot } from 'contexts/TypebotContext'
|
||||
@ -27,7 +27,7 @@ export const ConversationContainer = ({
|
||||
const { typebot, updateVariableValue } = useTypebot()
|
||||
const { document: frameDocument } = useFrame()
|
||||
const [displayedBlocks, setDisplayedBlocks] = useState<
|
||||
{ block: PublicBlock; startStepIndex: number }[]
|
||||
{ block: Block; startStepIndex: number }[]
|
||||
>([])
|
||||
const [localAnswer, setLocalAnswer] = useState<Answer | undefined>()
|
||||
const {
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
EmailInputStep,
|
||||
InputStepType,
|
||||
PhoneNumberInputStep,
|
||||
PublicStep,
|
||||
Step,
|
||||
UrlInputStep,
|
||||
Variable,
|
||||
} from 'models'
|
||||
@ -34,7 +34,7 @@ export const isInputValid = (
|
||||
}
|
||||
|
||||
export const stepCanBeRetried = (
|
||||
step: PublicStep
|
||||
step: Step
|
||||
): step is EmailInputStep | UrlInputStep | PhoneNumberInputStep =>
|
||||
isInputStep(step) && 'retryMessageContent' in step.options
|
||||
|
||||
|
@ -11,9 +11,9 @@ import {
|
||||
GoogleAnalyticsStep,
|
||||
WebhookStep,
|
||||
SendEmailStep,
|
||||
PublicBlock,
|
||||
ZapierStep,
|
||||
ResultValues,
|
||||
Block,
|
||||
} from 'models'
|
||||
import { stringify } from 'qs'
|
||||
import { sendRequest } from 'utils'
|
||||
@ -31,7 +31,7 @@ type IntegrationContext = {
|
||||
isPreview: boolean
|
||||
variables: Variable[]
|
||||
resultValues: ResultValues
|
||||
blocks: PublicBlock[]
|
||||
blocks: Block[]
|
||||
updateVariableValue: (variableId: string, value: string) => void
|
||||
}
|
||||
|
||||
@ -170,7 +170,6 @@ const executeWebhook = async (
|
||||
isPreview,
|
||||
}: IntegrationContext
|
||||
) => {
|
||||
if (!step.webhook) return step.outgoingEdgeId
|
||||
const { data, error } = await sendRequest({
|
||||
url: `${apiHost}/api/typebots/${typebotId}/blocks/${blockId}/steps/${stepId}/executeWebhook`,
|
||||
method: 'POST',
|
||||
@ -186,6 +185,7 @@ const executeWebhook = async (
|
||||
const value = safeEval(`(${JSON.stringify(data)}).${varMapping?.bodyPath}`)
|
||||
updateVariableValue(varMapping.variableId, value)
|
||||
})
|
||||
return step.outgoingEdgeId
|
||||
}
|
||||
|
||||
const sendEmail = async (
|
||||
|
Reference in New Issue
Block a user