import { useState } from "react"; import { Link } from "react-router-dom"; import { Game } from "../api/games"; export default function GameCard({ game }: { game: Game }) { const created = new Date(game.created_at).toLocaleString("de-DE"); const [copied, setCopied] = useState(false); async function handleCopyLink(e: React.MouseEvent) { e.preventDefault(); e.stopPropagation(); const link = `${window.location.origin}/games/${game.id}?code=${game.participation_code}`; await navigator.clipboard.writeText(link); setCopied(true); setTimeout(() => setCopied(false), 1500); } return (

{game.name}

{game.status === "ended" && ( Beendet )} {game.participation_code && ( )}

{game.description}

Erstellt: {created} Von: {game.creator_name} {game.player_count} Spieler {game.player_names.length > 0 && `: ${game.player_names.join(", ")}`} {game.has_adventure && 📖 Eigenes Abenteuer}
); }