mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
fixed a bit
This commit is contained in:
1 parent
45b0f98971
commit
a0fb2b9970
9 files changed
+314
-177
No files matched your search
@@ -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 }
|
||||
|
||||
Reference in new issue
Block a user