TEAM PAGE WORKS WITH 1 ERROR WOOOOOOOO

This commit is contained in:
bobbert committed 2025-03-12 19:56:19 +00:00
1 parent 68e9af2d83
commit 6b87e0f7fb
5 files changed
+284 -234

No files matched your search

+4 -26
View File
@@ -1,5 +1,4 @@
import { redirect } from "next/navigation";
import { query, queryOne } from "@/lib/db";
import { cookies } from "next/headers";
import { verifyToken } from "@/app/api/auth/[...nextauth]/route";
@@ -18,31 +17,10 @@ export async function GET(_, context) {
return redirect("/login");
}
const params = await context.params;
const teamId = params.teamId;
const team = await queryOne("SELECT * FROM teams WHERE id = ?", [teamId]);
if (!team) {
return new Response(
JSON.stringify({ success: false, error: "Team not found" }),
{ status: 404 }
);
}
const members = await query(
"SELECT id, username FROM users WHERE team_id = ?",
[teamId]
);
return new Response(JSON.stringify({ success: true, team, members }), {
status: 200,
});
// Instead of returning JSON, redirect to the page component
return redirect(`/${context.params.teamId}`);
} catch (error) {
console.error("Team fetch error:", error);
return new Response(
JSON.stringify({ success: false, error: "Failed to fetch team" }),
{ status: 500 }
);
console.error("Team route error:", error);
return redirect("/team-selection");
}
}