Show shared ranks for tied members on the team leaderboard
React · React · intermediate · modification
Members with the same points got different positions (#1 and #2) depending on the order the API sent them in, and people on the team page asked why. The new `src/team/rankMembers.js` sorts a copy of the members (most points first, then by name, then by id) and gives tied members the same rank, skipping past them as sports tables do. `src/team/Leaderboard.jsx` renders that rank in a column now headed Rank. Tests: `src/team/rankMembers.test.js` and `src/team/Leaderboard.test.jsx` (both new).
Team dashboard SPA on React 18.3 (Vite, function components). Tests run with `npm test`: Vitest 2 with @testing-library/react 16 in jsdom. Existing and unchanged: `TeamPage.jsx` renders `<Leaderboard members={members} />` once `useTeamPoints(teamId)` has loaded and shows the loading and error states itself; it passes the array from the hook's cache as is, so components must not modify it. `members` is an array of at most 200 `{ id, name, points }` objects (a team has at most 200 members): `id` is a unique non-empty string, `name` a non-empty display name in any script (two members can share a name), `points` the member's points this month, a non-negative safe integer (the API validates it). `Leaderboard.css` styles the table and the empty-state text.
Requirements
- The team leaderboard (`Leaderboard`, `members` prop) lists members by points, most first, and its first column shows each member's rank, headed `Rank` instead of `#`. Members with equal points share a rank and the next rank skips past them (standard competition ranking): points 120, 120, 90 are ranked 1, 1, 3.
- Members with equal points are listed by name in English collation order (`Intl.Collator('en')`), and members whose names compare equal by `id` in plain string order, so the list does not depend on the order the API returned the members in.
- The `members` array and its objects are not modified (they are the points hook's cached data).
- Unchanged: an empty list shows "No points yet this month." instead of the table; the table keeps its caption ("Team leaderboard"), the Member and Points columns and one row per member.
- The ranking has tests that run with the existing `npm test` (Vitest).
Files touched
- src/team/rankMembers.js
- src/team/Leaderboard.jsx
- src/team/rankMembers.test.js
- src/team/Leaderboard.test.jsx