diff --git a/packages/bot-engine/src/components/LiteBadge.tsx b/packages/bot-engine/src/components/LiteBadge.tsx new file mode 100644 index 000000000..d3ae31b32 --- /dev/null +++ b/packages/bot-engine/src/components/LiteBadge.tsx @@ -0,0 +1,46 @@ +import React, { useEffect, useRef } from 'react' +import { useFrame } from 'react-frame-component' + +export const LiteBadge = () => { + const { document } = useFrame() + const liteBadge = useRef(null) + + useEffect(() => { + const container = document.querySelector( + '[data-testid="container"]' + ) as HTMLDivElement + const observer = new MutationObserver(function (mutations_list) { + mutations_list.forEach(function (mutation) { + mutation.removedNodes.forEach(function (removed_node) { + if ((removed_node as HTMLElement).id == 'lite-badge') { + console.log('litebadge has been removed') + container.append(liteBadge.current as Node) + } + }) + }) + }) + observer.observe(container, { + subtree: false, + childList: true, + }) + + return () => { + observer.disconnect() + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + return ( + + Made with Typebot. + + ) +} diff --git a/packages/bot-engine/src/components/TypebotViewer.tsx b/packages/bot-engine/src/components/TypebotViewer.tsx index d6df92002..99ff78c7e 100644 --- a/packages/bot-engine/src/components/TypebotViewer.tsx +++ b/packages/bot-engine/src/components/TypebotViewer.tsx @@ -20,6 +20,7 @@ import { VariableWithValue, } from 'models' import { Log } from 'db' +import { LiteBadge } from './LiteBadge' export type TypebotViewerProps = { typebot: PublicTypebot @@ -113,17 +114,7 @@ export const TypebotViewer = ({ predefinedVariables={predefinedVariables} /> - {typebot.settings.general.isBrandingEnabled && ( - - Made with Typebot. - - )} + {typebot.settings.general.isBrandingEnabled && }