brackt/app/components/draft/picks-utils.ts
Chris Parsons 599bba8949
refactor: address code review findings in Roster/Summary draft views (#57)
- Extract groupPicksByTeamAndSport into shared picks-utils.ts to remove
  duplication between TeamRosterView and DraftSummaryView
- Fix TeamRosterView: make teamPicks a proper useMemo dep on selectedTeamId,
  add useEffect to reset stale selection if draftSlots changes
- Add accessible label/htmlFor to TeamRosterView team Select
- Remove dead `season` prop from DraftSummaryView (was inherited from
  TeamsDraftedGrid but never used)
- Fix DraftSummaryView: sport name cells are now <th scope="row">, column
  headers have scope="col", Total header uses solid bg-muted to match Sport
- Replace || null with explicit > 0 check in Total cell for clarity
- Consolidate to summaryViewProps/rosterViewProps in route for consistency

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 16:46:35 -08:00

19 lines
604 B
TypeScript

export type DraftPick = {
id: string;
team: { id: string; name: string };
participant: { id: string; name: string };
sport: { id: string; name: string };
};
export function groupPicksByTeamAndSport(
picks: DraftPick[]
): Map<string, Map<string, DraftPick[]>> {
const map = new Map<string, Map<string, DraftPick[]>>();
picks.forEach((pick) => {
if (!map.has(pick.team.id)) map.set(pick.team.id, new Map());
const teamMap = map.get(pick.team.id)!;
if (!teamMap.has(pick.sport.id)) teamMap.set(pick.sport.id, []);
teamMap.get(pick.sport.id)!.push(pick);
});
return map;
}