fix(leaderboard): align leaderboard API response parsing and podium rankings

Đang mở
#19 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@Rithish-2914 đang làm issue này rồi.

Từ ngày 18/9/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

enhancement
Problem
Problem

The Admin Leaderboard page (/leaderboard) fails to display participant rankings and podium standings due to API response structure mismatches:

  1. Empty Leaderboard & Undefined Data:

    • getLeaderboard() in src/api/users.ts expects { status: string, leaderboard: LeaderboardUser[] } and returns response.data.leaderboard.
    • The backend GET /admin/leaderboard returns { "message": "Leaderboard fetched successfully", "data": [ LeaderboardEntry... ] }.
    • Because response.data.leaderboard is undefined, the query returns undefined, leaving the podium and rest-of-the-field rankings blank.
  2. Field Mapping:

    • Backend returns rank, id, name, email, reg_no, score, round_qualified, total_runtime, total_submissions, solved_count, is_banned.
    • Frontend accessors require clean mapping into LeaderboardUser records.
  3. Podium Edge Cases:

    • The top 3 podium layout should gracefully handle cases where fewer than 3 users have submitted solutions.

Steps to Reproduce
  1. Start the backend and log into the Admin portal (cookoff-admin-11.0).
  2. Navigate to the Leader tab from the sidebar (/leaderboard).
  3. Observed Behavior: The leaderboard displays "No other participants yet" or an empty state because response.data.leaderboard is undefined.
  4. Inspect Network tab for GET /admin/leaderboard: the backend returns { "message": "...", "data": [...] } with snake_case fields.
  5. Expected Behavior: Top 3 participants should be highlighted on the podium with gold/silver/bronze trophies, scores, and rankings, with the remaining participants listed in "The Rest of the Field" table.

Proposed solution
  1. src/api/users.ts:
    • Define RawLeaderboardEntry and normalizeLeaderboardUser helper.
    • Update getLeaderboard() to unwrap response.data.data into normalized LeaderboardUser[].
  2. src/app/(protected)/leaderboard/page.tsx:
    • Ensure podium and field rankings consume normalized properties safely.
  3. Unit Tests:
    • Add unit test coverage in src/api/__tests__/users.test.ts for getLeaderboard and normalizeLeaderboardUser.
Alternatives considered

No response

Ngôn ngữ chính
TypeScript
Star
0
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeChefVIT/cookoff-admin-11.0

Tất cả issue của CodeChefVIT/cookoff-admin-11.0

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.