|
1 |
| -import React, { useEffect } from 'react' |
| 1 | +import React from 'react' |
2 | 2 | import { useQuery } from '@tanstack/react-query'
|
3 | 3 | import rehypeKatex from 'rehype-katex'
|
4 | 4 | import remarkGfm from 'remark-gfm'
|
5 | 5 | import remarkMath from 'remark-math'
|
6 | 6 |
|
7 | 7 | import { getConfiguration } from '@/apis/admin/configuration'
|
8 | 8 | import { MessageMarkdownMemoized } from './MessageMarkdownMemoized'
|
| 9 | +import {CalendlyWidget} from '@/app/(chat)/ask-anything/[chatId]/_components/CalendlyWidget' |
9 | 10 |
|
10 | 11 | interface ShowMessageProps {
|
11 | 12 | message: string
|
12 | 13 | components: object
|
13 | 14 | }
|
14 | 15 |
|
15 | 16 | const ShowMessage: React.FC<ShowMessageProps> = ({ message, components }) => {
|
16 |
| - useEffect(() => { |
17 |
| - if (message === 'BOOK_MEETING') { |
18 |
| - const script = document.createElement('script') |
19 |
| - script.src = 'https://assets.calendly.com/assets/external/widget.js' |
20 |
| - script.async = true |
21 |
| - document.body.appendChild(script) |
22 |
| - |
23 |
| - return () => { |
24 |
| - document.body.removeChild(script) |
25 |
| - } |
26 |
| - } |
27 |
| - }, [message]) |
28 |
| - |
29 | 17 | // Fetch Calendly URL from DB
|
30 | 18 | const { data: calendlyUrlData } = useQuery({
|
31 | 19 | queryKey: ['calendlyUrl'],
|
32 | 20 | queryFn: getConfiguration,
|
33 | 21 | })
|
34 | 22 |
|
35 |
| - const calendlyUrl = calendlyUrlData?.credentials[0].calendlyMeetingLink |
| 23 | + const calendlyUrl = calendlyUrlData?.credentials[0]?.calendlyMeetingLink || process.env.NEXT_PUBLIC_CALENDLY || '' |
36 | 24 |
|
37 | 25 | if (message === 'BOOK_MEETING') {
|
38 | 26 | return (
|
39 | 27 | <div className='mx-auto w-full min-w-full max-w-[1000px] overflow-hidden rounded-xl'>
|
40 |
| - <div |
41 |
| - className='calendly-inline-widget relative h-[500px] w-[285px] pb-[100%] sm:w-[300px] sm:pb-[75%] md:w-[420px]' |
42 |
| - data-url={calendlyUrl || process.env.NEXT_PUBLIC_CALENDLY} |
43 |
| - /> |
| 28 | + <CalendlyWidget url={calendlyUrl} /> |
44 | 29 | </div>
|
45 | 30 | )
|
46 | 31 | } else {
|
|
0 commit comments