feat: add tournament type and team support to tournament APIs

Update tournament APIs to support:
- tournamentType field (individual/team)
- Team creation for team tournaments
- Even number validation for team tournaments
- Automatic pairing of consecutive players into teams
This commit is contained in:
2026-04-03 19:27:31 -07:00
parent a75d7d3cc6
commit c3b0466092
3 changed files with 107 additions and 3 deletions
+5 -2
View File
@@ -69,7 +69,7 @@ export async function POST(request: Request) {
}
const body = await request.json();
const { name, format, eventDate, targetScore, allowTies } = body;
const { name, format, eventDate, targetScore, allowTies, maxParticipants, tournamentType } = body;
const tournament = await prisma.event.create({
data: {
@@ -77,10 +77,13 @@ export async function POST(request: Request) {
format: format || "round_robin",
eventDate: eventDate ? new Date(eventDate) : null,
eventType: "tournament",
tournamentType: tournamentType || "individual",
status: "planned",
ownerId: session.user.id, // Assign ownership to the creator
ownerId: session.user.id,
targetScore: targetScore ? parseInt(targetScore) : null,
allowTies: allowTies ?? false,
maxParticipants: maxParticipants ? parseInt(maxParticipants) : null,
description: body.description,
},
});