diff --git a/client/src/components/game/GamePage.tsx b/client/src/components/game/GamePage.tsx index 351abfe..1e3a118 100644 --- a/client/src/components/game/GamePage.tsx +++ b/client/src/components/game/GamePage.tsx @@ -40,6 +40,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { const [boardWidth, setBoardWidth] = useState(480); const [playBtnLoading, setPlayBtnLoading] = useState(false); + const [copiedLink, setCopiedLink] = useState(false); const chatlistRef = useRef(null); @@ -360,6 +361,19 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { } } + function copyInvite() { + const text = `https://ches.su/game/${initialLobby.code}`; + if ("clipboard" in navigator) { + navigator.clipboard.writeText(text); + } else { + document.execCommand("copy", true, text); + } + setCopiedLink(true); + setTimeout(() => { + setCopiedLink(false); + }, 5000); + } + return (
@@ -402,7 +416,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
-
+
{getPlayerHtml("top")}
vs
@@ -412,9 +426,22 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
Invite friends: -
- - ches.su/game/{initialLobby.code} {/* TODO */} +
+ +
+ copied to clipboard +