just need to fix the map to clue function.

This commit is contained in:
bobbert committed 2025-03-16 20:52:51 +00:00
1 parent 727555e70f
commit ea836179d6
6 files changed
+124 -43

No files matched your search

+22 -1
View File
@@ -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(