feat: add tournament creation wizard with participant management and bulk game entry
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.nextUrl);
|
||||
const query = searchParams.get("q");
|
||||
|
||||
if (!query || query.length < 2) {
|
||||
return NextResponse.json({ players: [] });
|
||||
}
|
||||
|
||||
// Search for players by name (case-insensitive, partial match)
|
||||
const players = await prisma.player.findMany({
|
||||
where: {
|
||||
name: {
|
||||
contains: query,
|
||||
},
|
||||
},
|
||||
orderBy: { name: "asc" },
|
||||
take: 20,
|
||||
});
|
||||
|
||||
return NextResponse.json({ players });
|
||||
} catch (error) {
|
||||
console.error("Player search error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to search players" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user