import { createClient } from "@/lib/supabase/server"; import { requireUser } from "@/lib/api/auth"; import { ApiError, apiError, apiSuccess } from "@/lib/api/errors"; import * as teams from "@/lib/services/teams"; export async function GET( _request: Request, { params }: { params: Promise<{ competitionId: string }> } ) { try { const { competitionId } = await params; const supabase = await createClient(); const user = await requireUser(supabase); const membership = await teams.getManagerTeam( supabase, user.id, competitionId ); if (!membership) { throw new ApiError(404, "You are not a manager in this competition"); } const teamId = membership.team_id; const dashboard = await teams.getTeamDashboard( supabase, teamId, competitionId ); return apiSuccess({ team: membership.teams, ...dashboard }); } catch (e) { return apiError(e); } }