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

Files touched

Review this PR

React practice