import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { Game, listGames } from "../api/games"; import GameCard from "../components/GameCard"; import GameSetupChat from "../components/GameSetupChat"; export default function GamesList() { const navigate = useNavigate(); const [games, setGames] = useState([]); const [loading, setLoading] = useState(true); const [showCreate, setShowCreate] = useState(false); async function load() { setLoading(true); try { setGames(await listGames()); } finally { setLoading(false); } } useEffect(() => { load(); }, []); return (

Spiele

{showCreate && navigate(`/games/${game.id}`)} />} {loading ? (

Lädt…

) : games.length === 0 ? (

Noch keine Spiele vorhanden.

) : (
{games.map((game) => ( ))}
)}
); }