diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx index d199083..8ab2d09 100644 --- a/client/src/app/page.tsx +++ b/client/src/app/page.tsx @@ -6,51 +6,74 @@ import PublicGames from "@/components/home/PublicGames/PublicGames"; import Link from "next/link"; import { useSession } from "@/context/session"; - export default function Home() { const { user } = useSession(); + const isLoggedIn = user?.id && typeof user.id === "number"; return ( -
- +
-
+ {/* Hauptaktionen */} +
- {/* Against AI */} -
-

Gegen KI spielen

- - ♟ Gegen Stockfish spielen - -
- -
oder
- - {/* Friends */} - {user?.id && typeof user.id === "number" && ( - <> -
-

Freunde

- - 👥 Freunde verwalten - +
+
+

♟ Spiel erstellen

+

Erstelle eine Partie und teile den Einladungslink mit Freunden

+
+
-
oder
- - )} - -
-

Per Einladung beitreten

- +
-
oder
- -
-

Spiel erstellen

- +
+
+

🤖 Gegen KI spielen

+

Fordere Stockfish auf verschiedenen Stufen heraus — von Anfänger bis Meister

+
+ Jetzt spielen +
+
+ +
+
+ {isLoggedIn ? ( + <> +

👥 Freunde

+

Freunde hinzufügen, verwalten und zu einer Partie einladen

+
+ Freunde verwalten +
+ + ) : ( + <> +

🔗 Einladung annehmen

+

Einladungslink oder Code eingeben um beizutreten

+ + + )} +
+
+
+ + {/* Öffentliche Spiele + Beitreten */} +
+
+ +
+ {isLoggedIn && ( +
+
+

🔗 Einladung annehmen

+

Link oder Code eingeben

+ +
+
+ )} +
+
); } diff --git a/client/src/components/game/GamePage.tsx b/client/src/components/game/GamePage.tsx index 751f118..b97a867 100644 --- a/client/src/components/game/GamePage.tsx +++ b/client/src/components/game/GamePage.tsx @@ -22,7 +22,7 @@ import { Chess } from "chess.js"; import type { ClearPremoves } from "react-chessboard"; import { Chessboard } from "react-chessboard"; -import { API_URL } from "@/config"; +import { API_URL, APP_URL } from "@/config"; import { io } from "socket.io-client"; import { lobbyReducer, squareReducer } from "./reducers"; @@ -408,12 +408,8 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { } function copyInvite() { - const text = `https://ches.su/${lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}`; - if ("clipboard" in navigator) { - navigator.clipboard.writeText(text); - } else { - document.execCommand("copy", true, text); - } + const text = `${APP_URL}/${lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}`; + navigator.clipboard.writeText(text).catch(() => {}); setCopiedLink(true); setTimeout(() => { setCopiedLink(false); @@ -586,7 +582,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { onClick={copyInvite} > - ches.su/{lobby.endReason ? `archive/${lobby.id}` : initialLobby.code} + {APP_URL.replace(/^https?:\/\//, "")}/{lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}
copied to clipboard diff --git a/client/src/components/home/CreateGame.tsx b/client/src/components/home/CreateGame.tsx index 839c08a..547c1aa 100644 --- a/client/src/components/home/CreateGame.tsx +++ b/client/src/components/home/CreateGame.tsx @@ -33,35 +33,35 @@ export default function CreateGame() { } return ( -
-