brackt/app/routes/leagues/$leagueId.standings.$seasonId.teams.$teamId.tsx
Chris Parsons f17699e4c5 feat: Implement team breakdown pages with detailed score breakdown
- Created `TeamScoreBreakdown` component to display all drafted participants, their placements, and points.
- Added new route for team breakdown at `/leagues/:leagueId/standings/:seasonId/teams/:teamId`.
- Enhanced `getTeamScoreBreakdown` model to include `sportsSeasonId` for grouping.
- Updated `StandingsTable` to include clickable team name links.
- Added functionality to finalize brackets in playoff events, including error handling and recalculating standings.
- Implemented tests for `TeamScoreBreakdown` component to ensure proper rendering and functionality.
- Updated routing to support new team breakdown feature and ensure seamless navigation.
2025-11-14 20:01:21 -08:00

49 lines
1.3 KiB
TypeScript

import { useLoaderData } from "react-router";
import type { Route } from "./+types/$leagueId.standings.$seasonId.teams.$teamId";
import { TeamScoreBreakdown } from "~/components/standings/TeamScoreBreakdown";
import { getTeamScoreBreakdown, getTeamStanding } from "~/models/standings";
/**
* Team score breakdown page
* Shows all drafted participants with their placements and points
* Phase 4.3: Team breakdown pages
*/
export async function loader({ params }: Route.LoaderArgs) {
const { leagueId, seasonId, teamId } = params;
// Get team breakdown with all picks
const breakdown = await getTeamScoreBreakdown(teamId, seasonId);
if (!breakdown) {
throw new Response("Team not found", { status: 404 });
}
// Get team standing for additional context
const standing = await getTeamStanding(teamId, seasonId);
return {
leagueId,
seasonId,
teamId,
breakdown: {
...breakdown,
team: breakdown.team || null,
},
standing,
};
}
export default function TeamBreakdownPage() {
const { leagueId, seasonId, breakdown, standing } = useLoaderData<typeof loader>();
return (
<div className="container mx-auto py-8 px-4">
<TeamScoreBreakdown
leagueId={leagueId}
seasonId={seasonId}
breakdown={breakdown}
standing={standing}
/>
</div>
);
}