feat: add targetScore and allowTies fields to tournament API routes
This commit is contained in:
@@ -146,6 +146,8 @@ export async function PUT(request: Request, { params }: RouteParams) {
|
|||||||
status,
|
status,
|
||||||
maxParticipants,
|
maxParticipants,
|
||||||
ownerId,
|
ownerId,
|
||||||
|
targetScore,
|
||||||
|
allowTies,
|
||||||
} = body;
|
} = body;
|
||||||
|
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
@@ -164,6 +166,8 @@ export async function PUT(request: Request, { params }: RouteParams) {
|
|||||||
eventType: eventType || "tournament",
|
eventType: eventType || "tournament",
|
||||||
format: format || "round_robin",
|
format: format || "round_robin",
|
||||||
maxParticipants: maxParticipants ? parseInt(maxParticipants) : null,
|
maxParticipants: maxParticipants ? parseInt(maxParticipants) : null,
|
||||||
|
targetScore: targetScore ? parseInt(targetScore) : null,
|
||||||
|
allowTies: allowTies ?? false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only allow status updates if they don't conflict with auto-calculation
|
// Only allow status updates if they don't conflict with auto-calculation
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { name, format, eventDate } = body;
|
const { name, format, eventDate, targetScore, allowTies } = body;
|
||||||
|
|
||||||
const tournament = await prisma.event.create({
|
const tournament = await prisma.event.create({
|
||||||
data: {
|
data: {
|
||||||
@@ -79,6 +79,8 @@ export async function POST(request: Request) {
|
|||||||
eventType: "tournament",
|
eventType: "tournament",
|
||||||
status: "planned",
|
status: "planned",
|
||||||
ownerId: session.user.id, // Assign ownership to the creator
|
ownerId: session.user.id, // Assign ownership to the creator
|
||||||
|
targetScore: targetScore ? parseInt(targetScore) : null,
|
||||||
|
allowTies: allowTies ?? false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user