ChenyuRabbitLove's picture
feat: add embeddedable chat component
c4412d0
raw
history blame contribute delete
847 Bytes
"use client";
import dynamic from 'next/dynamic';
import { useEffect } from 'react';
// Dynamically import the chat bot component with no SSR
const EmbeddableChatBot = dynamic(
() => import('@/app/components/embeddable-chat-bot'),
{ ssr: false }
);
export default function EmbedChatPage() {
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const config = {
apiUrl: params.get('apiUrl') || undefined,
theme: params.get('theme') as 'light' | 'dark' || 'light',
primaryColor: params.get('primaryColor') || '#FF6B6B',
placeholder: params.get('placeholder') || undefined,
buttonText: params.get('buttonText') || undefined,
};
if (window.parent) {
window.parent.postMessage({ type: 'CHAT_READY', config }, '*');
}
}, []);
return <EmbeddableChatBot />;
}