Spaces:
Sleeping
Sleeping
File size: 1,186 Bytes
a3e20c4 ad5d266 fcfd230 94f1dbe fcfd230 a3e20c4 fcfd230 a3e20c4 fcfd230 a3e20c4 94f1dbe fcfd230 94f1dbe ad5d266 94f1dbe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
"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 resp = await fetch(
`${process.env.API_URL || "http://localhost:8000"}/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 (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
{!starting ? (
<button
onClick={() => start()}
disabled={starting}
className="bg-white text-black rounded-xl p-4 px-6"
>
Connect
</button>
) : (
<div>
{roomUrl ? (
<Link href={roomUrl}>Open Room</Link>
) : (
"Waiting for bot to load..."
)}
</div>
)}
</main>
);
}
|