diff --git a/client/src/app/admin/page.tsx b/client/src/app/admin/page.tsx
index d06f13c..db2f9c1 100644
--- a/client/src/app/admin/page.tsx
+++ b/client/src/app/admin/page.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useEffect, useState } from "react";
+import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { API_URL } from "@/config";
import { useSession } from "@/context/session";
@@ -40,17 +40,12 @@ export default function AdminPage() {
if (user && user.role !== "admin") router.push("/");
}, [user, router]);
- useEffect(() => {
- fetchStats();
- fetchUsers();
- }, [page, search]);
-
- const fetchStats = async () => {
+ const fetchStats = useCallback(async () => {
const res = await fetch(`${API_URL}/v1/admin/stats`, { credentials: "include" });
if (res.ok) setStats(await res.json());
- };
+ }, []);
- const fetchUsers = async () => {
+ const fetchUsers = useCallback(async () => {
const params = new URLSearchParams({ limit: String(limit), offset: String(page * limit) });
if (search) params.set("search", search);
const res = await fetch(`${API_URL}/v1/admin/users?${params}`, { credentials: "include" });
@@ -59,7 +54,12 @@ export default function AdminPage() {
setUsers(data.users);
setTotal(data.total);
}
- };
+ }, [page, search, limit]);
+
+ useEffect(() => {
+ fetchStats();
+ fetchUsers();
+ }, [fetchStats, fetchUsers]);
const toggleBan = async (id: number, banned: boolean) => {
await fetch(`${API_URL}/v1/admin/users/${id}`, {
@@ -107,7 +107,6 @@ export default function AdminPage() {
Admin-Panel
- {/* Stats */}
{stats && (
@@ -125,15 +124,10 @@ export default function AdminPage() {
)}
- {/* Update Button */}
Website aktualisieren
Führt git pull im App-Verzeichnis aus. Container muss danach neugestartet werden.
-
- {/* User Management */}
Nutzerverwaltung
@@ -158,14 +151,7 @@ export default function AdminPage() {
- | ID |
- Name |
- E-Mail |
- W/L/D |
- Rolle |
- Status |
- Registriert |
- Aktionen |
+ ID | Name | E-Mail | W/L/D | Rolle | Status | Registriert | Aktionen |
@@ -176,9 +162,7 @@ export default function AdminPage() {
{u.email} |
{u.wins}/{u.losses}/{u.draws} |
-
- {u.role}
-
+ {u.role}
|
@@ -187,24 +171,13 @@ export default function AdminPage() {
|
{new Date(u.created_at).toLocaleDateString("de-DE")} |
- toggleBan(u.id, u.banned)}
- >
+ toggleBan(u.id, u.banned)}>
{u.banned ? "Entsperren" : "Sperren"}
- toggleAdmin(u.id, u.role)}
- disabled={u.id === (user.id as number)}
- >
+ toggleAdmin(u.id, u.role)} disabled={u.id === (user.id as number)}>
{u.role === "admin" ? "Admin entfernen" : "Admin machen"}
- deleteUser(u.id, u.name)}
- disabled={u.id === (user.id as number)}
- >
+ deleteUser(u.id, u.name)} disabled={u.id === (user.id as number)}>
Löschen
|
@@ -214,19 +187,10 @@ export default function AdminPage() {
- {/* Pagination */}
- setPage(p => p - 1)}>
- ← Zurück
-
+ setPage(p => p - 1)}>← Zurück
Seite {page + 1} — {total} Nutzer gesamt
- = total}
- onClick={() => setPage(p => p + 1)}
- >
- Weiter →
-
+ = total} onClick={() => setPage(p => p + 1)}>Weiter →
diff --git a/client/src/app/ai/page.tsx b/client/src/app/ai/page.tsx
index 291969d..63ab310 100644
--- a/client/src/app/ai/page.tsx
+++ b/client/src/app/ai/page.tsx
@@ -1,11 +1,10 @@
"use client";
-import { useState, useCallback, useEffect } from "react";
+import { useState, useCallback } from "react";
import { Chessboard } from "react-chessboard";
import { Chess } from "chess.js";
-import { useRouter } from "next/navigation";
import { API_URL } from "@/config";
-import { useSession } from "@/context/session";
+import type { CSSProperties } from "react";
const AI_LEVELS = [
{ level: 1, name: "Anfänger" },
@@ -17,8 +16,6 @@ const AI_LEVELS = [
];
export default function AiGamePage() {
- const { user } = useSession();
- const router = useRouter();
const [selectedLevel, setSelectedLevel] = useState(3);
const [gameStarted, setGameStarted] = useState(false);
const [game, setGame] = useState(new Chess());
@@ -105,7 +102,7 @@ export default function AiGamePage() {
setStatus("");
};
- const customSquareStyles: Record = {};
+ const customSquareStyles: Record = {};
if (lastMove) {
customSquareStyles[lastMove.from] = { backgroundColor: "rgba(255, 255, 0, 0.4)" };
customSquareStyles[lastMove.to] = { backgroundColor: "rgba(255, 255, 0, 0.4)" };