Make the participation code copyable as a shareable invite link
The code was shown as plain text on the game card with no way to copy
it. It's now a button that copies a full invite link
(origin/games/{id}?code={code}) to the clipboard instead of just the
bare code, since the recipient still needs the game id to get there.
GameSession's join form reads that ?code= param on mount and
pre-fills the input, so following the link lands straight on "click
Beitreten" instead of needing the code typed in by hand.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { FormEvent, useEffect, useState } from "react";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { Link, useParams, useSearchParams } from "react-router-dom";
|
||||
|
||||
import { listCharacters, Character } from "../api/characters";
|
||||
import { Game, getFullMessages, getGame, getRecentMessages, joinGame, Message } from "../api/games";
|
||||
@@ -9,6 +9,7 @@ import { useGameSocket } from "../hooks/useGameSocket";
|
||||
|
||||
export default function GameSession() {
|
||||
const { gameId } = useParams<{ gameId: string }>();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const [game, setGame] = useState<Game | null>(null);
|
||||
const [messages, setMessages] = useState<Message[]>([]);
|
||||
@@ -16,7 +17,7 @@ export default function GameSession() {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const [characters, setCharacters] = useState<Character[]>([]);
|
||||
const [joinCode, setJoinCode] = useState("");
|
||||
const [joinCode, setJoinCode] = useState(() => (searchParams.get("code") ?? "").toUpperCase());
|
||||
const [selectedCharacterId, setSelectedCharacterId] = useState("");
|
||||
const [joinError, setJoinError] = useState<string | null>(null);
|
||||
const [isTyping, setIsTyping] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user