2
0

feat(editor): Restore published version button

Had to migrate webhooks into a standalone table
This commit is contained in:
Baptiste Arnaud
2022-03-01 07:13:09 +01:00
parent 0df719d531
commit e17a1a0869
46 changed files with 578 additions and 348 deletions

View File

@ -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]

View File

@ -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()

View File

@ -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 {

View File

@ -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

View File

@ -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 (