| 1 |
import React, { Fragment, useEffect, useRef } from 'react'; |
| 2 |
import UIOverlay from '../UIComponents/UIOverlay'; |
| 3 |
import PreviewDisabled from '../Common/PreviewDisabled'; |
| 4 |
|
| 5 |
interface IPreviewForm { |
| 6 |
url: string; |
| 7 |
fullSiteEditor?: boolean; |
| 8 |
} |
| 9 |
|
| 10 |
export default function PreviewForm({ url, fullSiteEditor }: IPreviewForm) { |
| 11 |
const inputEl = useRef<HTMLDivElement>(null); |
| 12 |
|
| 13 |
useEffect(() => { |
| 14 |
if (inputEl.current) { |
| 15 |
//@ts-expect-error Hubspot global |
| 16 |
const hbspt = window.parent.hbspt || window.hbspt; |
| 17 |
hbspt.meetings.create('.meetings-iframe-container'); |
| 18 |
} |
| 19 |
}, [url, inputEl]); |
| 20 |
|
| 21 |
if (fullSiteEditor) { |
| 22 |
return <PreviewDisabled />; |
| 23 |
} |
| 24 |
|
| 25 |
return ( |
| 26 |
<Fragment> |
| 27 |
{url && ( |
| 28 |
<UIOverlay |
| 29 |
ref={inputEl} |
| 30 |
className="meetings-iframe-container" |
| 31 |
data-src={`${url}?embed=true`} |
| 32 |
></UIOverlay> |
| 33 |
)} |
| 34 |
</Fragment> |
| 35 |
); |
| 36 |
} |
| 37 |
|