File size: 847 Bytes
c4412d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"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 />;
}