From 9201b2c437bdc97f38942db6c7c741f0c95cc401 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Mon, 30 Mar 2026 21:51:26 -0700 Subject: [PATCH] feat: add admin player management page --- src/app/admin/players/page.tsx | 133 +++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/app/admin/players/page.tsx diff --git a/src/app/admin/players/page.tsx b/src/app/admin/players/page.tsx new file mode 100644 index 0000000..a54e189 --- /dev/null +++ b/src/app/admin/players/page.tsx @@ -0,0 +1,133 @@ +import { prisma } from "@/lib/prisma" +import Navigation from "@/components/Navigation" +import Link from "next/link" +import { redirect } from "next/navigation" +import { getSession } from "@/lib/auth-simple" +import { hasRole } from "@/lib/permissions" + +export default async function AdminPlayersPage() { + const session = await getSession() + + if (!session) { + redirect("/auth/login") + } + + // Only site_admin and club_admin can manage players + const permission = await hasRole('club_admin') + if (!permission.allowed) { + redirect("/auth/login") + } + + // Get all players with their user association + const players = await prisma.player.findMany({ + include: { + user: true, + }, + orderBy: { name: "asc" }, + }) + + // Get total count + const playerCount = await prisma.player.count() + + return ( +
+ + +
+
+ {/* Page Header */} +
+
+

Player Management

+

+ Manage {playerCount} player{playerCount !== 1 ? 's' : ''} in the system +

+
+
+ + {/* Player Table */} +
+ + + + + + + + + + + + + + {players.map((player) => ( + + + + + + + + + + ))} + +
+ Player Name + + Current Elo + + Games + + Record + + Win Rate + + User Account + + Actions +
+
+
+ + {player.name.charAt(0).toUpperCase()} + +
+
+
+ {player.name} +
+
+
+
+ {player.currentElo} + + {player.gamesPlayed} + + {player.wins}-{player.losses} + + {player.gamesPlayed > 0 + ? ((player.wins / player.gamesPlayed) * 100).toFixed(1) + '%' + : 'N/A'} + + {player.user ? ( + + {player.user.email} + + ) : ( + No account + )} + + + View Profile + +
+
+
+
+
+ ) +}