2
0

(wp) Add custom api host for WP plugin

This commit is contained in:
Baptiste Arnaud
2023-03-09 14:59:23 +01:00
parent 6b08df71ba
commit ddd20f6235
8 changed files with 35 additions and 10 deletions

View File

@ -14,6 +14,8 @@ import { useState } from 'react'
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
import { parseInitBubbleCode } from '../../../snippetParsers'
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
import { isCloudProdInstance } from '@/utils/helpers'
import { env, getViewerUrl } from 'utils'
type Props = {
publicId: string
@ -29,6 +31,9 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
const initCode = parseInitBubbleCode({
typebot: publicId,
apiHost: isCloudProdInstance
? undefined
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
theme: {
...theme,
chatWindow: {

View File

@ -11,6 +11,8 @@ import {
import { useState } from 'react'
import { PopupSettings } from '../../../settings/PopupSettings'
import { parseInitPopupCode } from '../../../snippetParsers/popup'
import { isCloudProdInstance } from '@/utils/helpers'
import { env, getViewerUrl } from 'utils'
type Props = {
publicId: string
@ -20,6 +22,9 @@ export const WordpressPopupInstructions = ({ publicId }: Props) => {
const initCode = parseInitPopupCode({
typebot: publicId,
apiHost: isCloudProdInstance
? undefined
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
autoShowDelay,
})

View File

@ -11,6 +11,8 @@ import {
} from '@chakra-ui/react'
import { useState } from 'react'
import { StandardSettings } from '../../../settings/StandardSettings'
import { isCloudProdInstance } from '@/utils/helpers'
import { env, getViewerUrl } from 'utils'
type Props = {
publicId: string
@ -73,8 +75,10 @@ const parseWordpressShortcode = ({
height?: string
publicId: string
}) => {
return `[typebot typebot="${publicId}"${width ? ` width="${width}"` : ''}${
height ? ` height="${height}"` : ''
}]
return `[typebot typebot="${publicId}"${
isCloudProdInstance
? ''
: ` apiHost="${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}"`
}${width ? ` width="${width}"` : ''}${height ? ` height="${height}"` : ''}]
`
}