mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
Made it so the team members page shows more than one user and fixed the issue so that multiple users can join the same team. Team GUI needs to be worked on however.
This commit is contained in:
1 parent
6b87e0f7fb
commit
95b4f9cc07
6 files changed
+50
-93
No files matched your search
@@ -2,6 +2,8 @@ import { query, queryOne } from "@/lib/db";
|
||||
import { cookies } from "next/headers";
|
||||
import { verifyToken } from "@/app/api/auth/[...nextauth]/route";
|
||||
|
||||
export const dynamic = "force-dynamic"; // Disable static rendering and caching
|
||||
|
||||
export async function GET(request, context) {
|
||||
try {
|
||||
// Use our custom token verification
|
||||
@@ -17,7 +19,9 @@ export async function GET(request, context) {
|
||||
return Response.json({ error: "Invalid session" }, { status: 401 });
|
||||
}
|
||||
|
||||
const teamId = context.params.teamId;
|
||||
// Properly await the params object before accessing it
|
||||
const params = context.params || {};
|
||||
const teamId = params.teamId;
|
||||
|
||||
// Validate teamId
|
||||
if (!teamId || isNaN(parseInt(teamId, 10))) {
|
||||
@@ -30,18 +34,27 @@ export async function GET(request, context) {
|
||||
return Response.json({ error: "Team not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
// Use a fresh query to get the latest team members each time
|
||||
const members = await query(
|
||||
"SELECT id, username FROM users WHERE team_id = ?",
|
||||
"SELECT id, username FROM users WHERE team_id = ? ORDER BY username ASC",
|
||||
[teamId]
|
||||
);
|
||||
|
||||
const timestamp = new Date().toISOString(); // Add timestamp for debugging
|
||||
|
||||
return Response.json(
|
||||
{
|
||||
success: true,
|
||||
team,
|
||||
members,
|
||||
refreshed: timestamp,
|
||||
},
|
||||
{ status: 200 }
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"Cache-Control": "no-store, max-age=0", // Prevent caching
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Team fetch error:", error);
|
||||
|
||||
Reference in new issue
Block a user