2
0

(editor) Add unpublish and close typebot options

Introducing more menu items on the "Publised" button in the editor. You can now unpublish a typebot and close it to new
responses
This commit is contained in:
Baptiste Arnaud
2022-10-06 08:33:46 +02:00
parent 7ca97d4606
commit bfed599695
80 changed files with 1112 additions and 961 deletions

View File

@ -24,7 +24,7 @@ import { LiteBadge } from './LiteBadge'
import { getViewerUrl, isEmpty } from 'utils'
export type TypebotViewerProps = {
typebot: PublicTypebot
typebot: Omit<PublicTypebot, 'updatedAt' | 'createdAt'>
isPreview?: boolean
apiHost?: string
style?: CSSProperties

View File

@ -1,3 +1,4 @@
import { TypebotViewerProps } from 'components/TypebotViewer'
import { Log } from 'db'
import { Edge, PublicTypebot, Typebot } from 'models'
import React, {
@ -20,7 +21,7 @@ export type LinkedTypebotQueue = {
const typebotContext = createContext<{
currentTypebotId: string
typebot: PublicTypebot
typebot: TypebotViewerProps['typebot']
linkedTypebots: LinkedTypebot[]
apiHost: string
isPreview: boolean
@ -49,13 +50,14 @@ export const TypebotContext = ({
onNewLog,
}: {
children: ReactNode
typebot: PublicTypebot
typebot: TypebotViewerProps['typebot']
apiHost: string
isLoading: boolean
isPreview: boolean
onNewLog: (log: Omit<Log, 'id' | 'createdAt' | 'resultId'>) => void
}) => {
const [localTypebot, setLocalTypebot] = useState<PublicTypebot>(typebot)
const [localTypebot, setLocalTypebot] =
useState<TypebotViewerProps['typebot']>(typebot)
const [linkedTypebots, setLinkedTypebots] = useState<LinkedTypebot[]>([])
const [currentTypebotId, setCurrentTypebotId] = useState(typebot.typebotId)
const [linkedBotQueue, setLinkedBotQueue] = useState<LinkedTypebotQueue>([])

View File

@ -1,3 +1,4 @@
import { TypebotViewerProps } from 'components/TypebotViewer'
import { LinkedTypebot } from 'contexts/TypebotContext'
import { Log } from 'db'
import {
@ -26,7 +27,7 @@ type EdgeId = string
type LogicContext = {
isPreview: boolean
apiHost: string
typebot: PublicTypebot
typebot: TypebotViewerProps['typebot']
linkedTypebots: LinkedTypebot[]
currentTypebotId: string
pushEdgeIdInLinkedTypebotQueue: (bot: {
@ -46,7 +47,7 @@ export const executeLogic = async (
context: LogicContext
): Promise<{
nextEdgeId?: EdgeId
linkedTypebot?: PublicTypebot | LinkedTypebot
linkedTypebot?: TypebotViewerProps['typebot'] | LinkedTypebot
}> => {
switch (block.type) {
case LogicBlockType.SET_VARIABLE: