"use client"; import { useCallback, useEffect, useRef } from "react"; import "@whereby.com/browser-sdk/embed"; import { Box, Button, HStack, Text, Link } from "@chakra-ui/react"; import { toaster } from "../components/ui/toaster"; interface WherebyEmbedProps { roomUrl: string; onLeave?: () => void; } // currently used for webinars only export default function WherebyWebinarEmbed({ roomUrl, onLeave, }: WherebyEmbedProps) { const wherebyRef = useRef(null); // TODO extract common toast logic / styles to be used by consent toast on normal rooms useEffect(() => { if (roomUrl && !localStorage.getItem("recording-notice-dismissed")) { const toastIdPromise = toaster.create({ placement: "top", duration: null, render: ({ dismiss }) => ( This webinar is being recorded. By continuing, you agree to our{" "} Privacy Policy ), }); return () => { toastIdPromise.then((id) => toaster.dismiss(id)); }; } }, [roomUrl]); const handleLeave = () => { if (onLeave) { onLeave(); } }; useEffect(() => { wherebyRef.current?.addEventListener("leave", handleLeave); return () => { wherebyRef.current?.removeEventListener("leave", handleLeave); }; }, [handleLeave]); return ( ); }