"use client"; import Link from "next/link"; import { useState } from "react"; export default function Home() { const [starting, setStarting] = useState(false); const [roomUrl, setRoomUrl] = useState(); async function start() { setStarting(true); const apiUrl = `${ window.location.protocol === "https:" ? "https" : "http" }:${window.location.host}`; const resp = await fetch(`${process.env.API_URL || apiUrl}/start`, { method: "POST", mode: "cors", cache: "no-cache", credentials: "same-origin", headers: { "Content-Type": "application/json", }, body: JSON.stringify({}), }); const data = await resp.json(); setRoomUrl(data.room_url); } return (
{!starting ? ( ) : (
{roomUrl ? ( Open Room ) : ( "Waiting for bot to load..." )}
)}
); }