import React, { useRef } from "react"; import { t } from "../../i18n"; import { Dialog } from "../../components/Dialog"; import { copyTextToSystemClipboard } from "../../clipboard"; import { ToolButton } from "../../components/ToolButton"; import { clipboard, start, stop } from "../../components/icons"; import "./RoomDialog.scss"; import { EVENT_SHARE, trackEvent } from "../../analytics"; const RoomDialog = ({ handleClose, activeRoomLink, username, onUsernameChange, onRoomCreate, onRoomDestroy, setErrorMessage, }: { handleClose: () => void; activeRoomLink: string; username: string; onUsernameChange: (username: string) => void; onRoomCreate: () => void; onRoomDestroy: () => void; setErrorMessage: (message: string) => void; }) => { const roomLinkInput = useRef(null); const copyRoomLink = async () => { try { await copyTextToSystemClipboard(activeRoomLink); trackEvent(EVENT_SHARE, "copy link"); } catch (error) { setErrorMessage(error.message); } if (roomLinkInput.current) { roomLinkInput.current.select(); } }; const selectInput = (event: React.MouseEvent) => { if (event.target !== document.activeElement) { event.preventDefault(); (event.target as HTMLInputElement).select(); } }; const renderRoomDialog = () => { return (
{!activeRoomLink && ( <>

{t("roomDialog.desc_intro")}

{`🔒 ${t("roomDialog.desc_privacy")}`}

)} {activeRoomLink && ( <>

{t("roomDialog.desc_inProgressIntro")}

{t("roomDialog.desc_shareLink")}

onUsernameChange(event.target.value)} onBlur={() => trackEvent(EVENT_SHARE, "name")} onKeyPress={(event) => event.key === "Enter" && handleClose()} />

{" "} {t("roomDialog.desc_privacy")}

{t("roomDialog.desc_exitSession")}

)}
); }; return ( {renderRoomDialog()} ); }; export default RoomDialog;