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

Abierto
#19 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@Rithish-2914 ya está trabajando en esto.

Desde el 18/9/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
0
Forks
1
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeChefVIT/cookoff-admin-11.0

Todos los issues de CodeChefVIT/cookoff-admin-11.0

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.