feat: add player name editing functionality in admin UI and fix site_admin access to admin dashboard
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
/**
|
||||
* GET /api/players
|
||||
*
|
||||
* Get all players with their user associations
|
||||
* This is a public endpoint (no authentication required)
|
||||
*/
|
||||
export async function GET() {
|
||||
try {
|
||||
const players = await prisma.player.findMany({
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
email: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { name: "asc" },
|
||||
});
|
||||
|
||||
return NextResponse.json(players);
|
||||
} catch (error: unknown) {
|
||||
console.error("Error fetching players:", error);
|
||||
const message = error instanceof Error ? error.message : "Failed to fetch players";
|
||||
return NextResponse.json(
|
||||
{ error: message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user