🐛 Improve bot libs mount in prod env
This commit is contained in:
@ -3,9 +3,8 @@ import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
||||
import { injectCustomHeadCode, isNotEmpty } from 'utils'
|
||||
import { getInitialChatReplyQuery } from '@/queries/getInitialChatReplyQuery'
|
||||
import { ConversationContainer } from './ConversationContainer'
|
||||
import type { ChatReply, StartParams } from 'models'
|
||||
import { setIsMobile } from '@/utils/isMobileSignal'
|
||||
import { BotContext, InitialChatReply } from '@/types'
|
||||
import { BotContext, InitialChatReply, OutgoingLog } from '@/types'
|
||||
import { ErrorMessage } from './ErrorMessage'
|
||||
import {
|
||||
getExistingResultIdFromSession,
|
||||
@ -13,13 +12,18 @@ import {
|
||||
} from '@/utils/sessionStorage'
|
||||
import { setCssVariablesValue } from '@/utils/setCssVariablesValue'
|
||||
|
||||
export type BotProps = StartParams & {
|
||||
export type BotProps = {
|
||||
typebot: string | any
|
||||
isPreview?: boolean
|
||||
resultId?: string
|
||||
startGroupId?: string
|
||||
prefilledVariables?: Record<string, unknown>
|
||||
apiHost?: string
|
||||
onNewInputBlock?: (ids: { id: string; groupId: string }) => void
|
||||
onAnswer?: (answer: { message: string; blockId: string }) => void
|
||||
onInit?: () => void
|
||||
onEnd?: () => void
|
||||
onNewLogs?: (logs: ChatReply['logs']) => void
|
||||
onNewLogs?: (logs: OutgoingLog[]) => void
|
||||
}
|
||||
|
||||
export const Bot = (props: BotProps & { class?: string }) => {
|
||||
@ -138,7 +142,7 @@ type BotContentProps = {
|
||||
onNewInputBlock?: (block: { id: string; groupId: string }) => void
|
||||
onAnswer?: (answer: { message: string; blockId: string }) => void
|
||||
onEnd?: () => void
|
||||
onNewLogs?: (logs: ChatReply['logs']) => void
|
||||
onNewLogs?: (logs: OutgoingLog[]) => void
|
||||
}
|
||||
|
||||
const BotContent = (props: BotContentProps) => {
|
||||
|
@ -2,7 +2,7 @@ import type { ChatReply, Theme } from 'models'
|
||||
import { createEffect, createSignal, For, Show } from 'solid-js'
|
||||
import { sendMessageQuery } from '@/queries/sendMessageQuery'
|
||||
import { ChatChunk } from './ChatChunk'
|
||||
import { BotContext, InitialChatReply } from '@/types'
|
||||
import { BotContext, InitialChatReply, OutgoingLog } from '@/types'
|
||||
import { isNotDefined } from 'utils'
|
||||
import { executeClientSideAction } from '@/utils/executeClientSideActions'
|
||||
import { LoadingChunk } from './LoadingChunk'
|
||||
@ -38,7 +38,7 @@ type Props = {
|
||||
onNewInputBlock?: (ids: { id: string; groupId: string }) => void
|
||||
onAnswer?: (answer: { message: string; blockId: string }) => void
|
||||
onEnd?: () => void
|
||||
onNewLogs?: (logs: ChatReply['logs']) => void
|
||||
onNewLogs?: (logs: OutgoingLog[]) => void
|
||||
}
|
||||
|
||||
export const ConversationContainer = (props: Props) => {
|
||||
|
@ -13,8 +13,7 @@ const defaultIconColor = 'white'
|
||||
export const BubbleButton = (props: Props) => {
|
||||
return (
|
||||
<button
|
||||
// eslint-disable-next-line solid/reactivity
|
||||
onClick={props.toggleBot}
|
||||
onClick={() => props.toggleBot()}
|
||||
class={
|
||||
'absolute bottom-4 right-4 shadow-md w-12 h-12 rounded-full hover:scale-110 active:scale-95 transition-transform duration-200 flex justify-center items-center animate-fade-in'
|
||||
}
|
||||
|
@ -39,10 +39,11 @@ export const Popup = (props: PopupProps) => {
|
||||
|
||||
const [isBotOpened, setIsBotOpened] = createSignal(
|
||||
// eslint-disable-next-line solid/reactivity
|
||||
popupProps.isOpen ?? popupProps.defaultOpen ?? false
|
||||
popupProps.isOpen ?? false
|
||||
)
|
||||
|
||||
onMount(() => {
|
||||
if (popupProps.defaultOpen) openBot()
|
||||
window.addEventListener('message', processIncomingEvent)
|
||||
const autoShowDelay = popupProps.autoShowDelay
|
||||
if (isDefined(autoShowDelay)) {
|
||||
|
@ -16,3 +16,9 @@ export type InitialChatReply = ChatReply & {
|
||||
typebot: NonNullable<ChatReply['typebot']>
|
||||
sessionId: NonNullable<ChatReply['sessionId']>
|
||||
}
|
||||
|
||||
export type OutgoingLog = {
|
||||
status: string
|
||||
description: string
|
||||
details?: unknown
|
||||
}
|
||||
|
Reference in New Issue
Block a user