'use client'; import Image from "next/image"; import { useRef, useState } from "react"; export default function Home() { const nameInputRef = useRef(null); const addPlayer = async () => { const playerName = nameInputRef.current?.value?.trim(); if (!playerName) { alert("Please enter a player name"); return; } try { const res = await fetch('http://localhost:8080/add', { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: playerName, group: selectedGroup }), }); if (!res.ok) { throw new Error(`Server error: ${res.statusText}`); } if (nameInputRef.current) { nameInputRef.current.value = ""; } } catch (error) { console.error("Failed to add player:", error); } }; const [selectedGroup, setSelectedGroup] = useState<"stripes" | "solids">("stripes"); return (
Vercel logomark Start Game Reset Game
); }