mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
just need to fix the map to clue function.
This commit is contained in:
1 parent
727555e70f
commit
ea836179d6
6 files changed
+124
-43
No files matched your search
@@ -46,6 +46,17 @@ export async function POST(request) {
|
||||
)
|
||||
`);
|
||||
|
||||
// Check if team name already exists
|
||||
const existingTeam = await queryOne("SELECT id FROM teams WHERE name = ?", [
|
||||
name,
|
||||
]);
|
||||
if (existingTeam) {
|
||||
return Response.json(
|
||||
{ error: "Team name already exists" },
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
|
||||
// Insert team without created_by field
|
||||
const result = await run("INSERT INTO teams (name, code) VALUES (?, ?)", [
|
||||
name,
|
||||
@@ -53,11 +64,21 @@ export async function POST(request) {
|
||||
]);
|
||||
|
||||
const teamId = result.lastID;
|
||||
if (!teamId) {
|
||||
throw new Error("Failed to create team - no ID returned");
|
||||
}
|
||||
|
||||
// Update the user's team_id
|
||||
await run("UPDATE users SET team_id = ? WHERE id = ?", [teamId, userId]);
|
||||
|
||||
return Response.json({ success: true, teamId, code });
|
||||
// Return a more complete response with all needed data
|
||||
return Response.json({
|
||||
success: true,
|
||||
teamId,
|
||||
teamName: name,
|
||||
code,
|
||||
message: "Team created successfully",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Create team error:", error);
|
||||
return Response.json(
|
||||
|
||||
Reference in new issue
Block a user