brackt/app/routes/leagues/$leagueId.standings.$seasonId.teams.$teamId.tsx
Chris Parsons 33f9ad6ebe
Simplify team breakdown page layout and fix code quality issues (#155)
- Replace per-sport cards with a single flat table; add Sport column (linked to sport season) before Participant
- Replace three summary stat cards with a compact "X remaining" line in the header
- Format pick numbers as round.pick notation (e.g. 2.02 for pick 16 in a 14-team league)
- Add getNumTeamsInSeason model function to compute pick-within-round correctly
- Remove dead bySport/totalPoints from standings model and component interface
- Narrow standing prop type to only currentRank (placementCounts was unused)
- Guard against numTeams === 0 edge case in pick notation
- Fix 0.0 → 0.00 decimal inconsistency
- Fix unsafe finalPosition! non-null assertion (null treated as Did Not Score)
- Update tests to match current UI; add coverage for new edge cases

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 09:20:41 -07:00

58 lines
1.6 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";
import { getNumTeamsInSeason } from "~/models/draft-slot";
export function meta({ data }: Route.MetaArgs): Route.MetaDescriptors {
return [{ title: `${data?.breakdown?.team?.name ?? "Team"} - Brackt` }];
}
/**
* 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, standing, numTeams] = await Promise.all([
getTeamScoreBreakdown(teamId, seasonId),
getTeamStanding(teamId, seasonId),
getNumTeamsInSeason(seasonId),
]);
if (!breakdown) {
throw new Response("Team not found", { status: 404 });
}
return {
leagueId,
seasonId,
teamId,
breakdown: {
...breakdown,
team: breakdown.team || null,
},
standing,
numTeams,
};
}
export default function TeamBreakdownPage() {
const { leagueId, seasonId, breakdown, standing, numTeams } = useLoaderData<typeof loader>();
return (
<div className="container mx-auto py-8 px-4">
<TeamScoreBreakdown
leagueId={leagueId}
seasonId={seasonId}
breakdown={breakdown}
standing={standing}
numTeams={numTeams}
/>
</div>
);
}