fixed a bit

This commit is contained in:
bobbert committed 2025-03-11 23:02:22 +00:00
1 parent 45b0f98971
commit a0fb2b9970
9 files changed
+314 -177

No files matched your search

+11 -6
View File
@@ -1,5 +1,5 @@
// app/api/teams/[teamId]/route.js
import { queryOne } from "../../../../lib/db";
import { queryOne, query } from "../../../../lib/db";
import { getServerSession } from "next-auth/next";
import { authOptions } from "../../../api/auth/[...nextauth]/route";
@@ -32,9 +32,10 @@ export async function GET(request, context) {
);
}
const team = await queryOne("SELECT * FROM teams WHERE id = ?", [
requestedTeamId,
]);
const team = await queryOne(
"SELECT id, name, code FROM teams WHERE id = ?",
[requestedTeamId]
);
if (!team) {
return new Response(JSON.stringify({ error: "Team not found" }), {
@@ -42,9 +43,13 @@ export async function GET(request, context) {
});
}
return new Response(JSON.stringify(team), { status: 200 });
const members = await query(
"SELECT id, username FROM users WHERE team_id = ?",
[requestedTeamId]
);
return new Response(JSON.stringify({ team, members }), { status: 200 });
} catch (error) {
console.error("Team fetch error:", error);
return new Response(
JSON.stringify({ error: "Failed to fetch team details" }),
{ status: 500 }