fix(users): align user management API response parsing and field mapping
@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ả
What happened?
Problem
The Admin User Management page (/users) is unable to render users and perform moderation actions due to API contract mismatches:
-
Empty Users Table:
getUsers()insrc/api/users.tsexpects an un-enveloped response{ status: string, users: User[], next_cursor?: string }.- The backend
GET /admin/usersreturns standard envelope{ "message": "Users fetched successfully", "data": [ UserResponse... ] }. - Because
response.data.usersisundefined, the TanStack table receives an empty array and displays no users.
-
Field Mapping & Ban/Unban Parsing:
- Backend
UserResponsereturns snake_case fields (id,name,email,reg_no,role,round_qualified,is_banned,balance,score), which need consistent normalization into the frontendUsermodel. banUserandunbanUserneed response handling aligned with{ message: string, data: UserResponse }.
- Backend
-
User Upgrade Request Body:
upgradeUserToRound()currently sends an empty POST body toPOST /admin/users/:id/upgrade, whereas the backend expectsUpgradeUserRequestcontaininground_qualified/role.
Proposed Solution
-
Update
src/api/users.ts:- Unwrap
response.data.dataingetUsers()and normalizeid,name,email,reg_no,role,round_qualified, andis_banned. - Update
banUser()andunbanUser()to handle backend response envelopes. - Allow passing
roundQualifiedandroleinupgradeUserToRound().
- Unwrap
-
Update
src/app/(protected)/users/page.tsx&user-columns.tsx:- Ensure table accessors read the normalized
Userdata. - Fix pagination display text.
- Ensure table accessors read the normalized
Affected Files
src/api/users.tssrc/app/(protected)/users/page.tsxsrc/app/(protected)/users/user-columns.tsx
Steps to reproduce
Steps to Reproduce
- Start the Go backend and log into the Admin portal (
cookoff-admin-11.0) with an admin account. - Navigate to the Users tab from the sidebar (
/users). - Observed Behavior: The table remains completely empty with no user rows rendered, despite users existing in the database (since
response.data.usersisundefined). - Inspect Network tab for
GET /admin/users: the response returns{ "message": "Users fetched successfully", "data": [...] }with snake_case keys (id,reg_no,round_qualified), but the frontend expects{ users: [...] }and PascalCase keys (ID,RegNo,RoundQualified). - Triggering Ban/Unban or user upgrade fails to handle response wrappers or sends empty upgrade payloads.
Expected Behavior
/usersshould unwrapresponse.data.data, populate the table with all registered users, correctly display details (Name, RegNo, Email, Round, Role), and allow instant banning/unbanning and round upgrades
Environment
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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CodeChefVIT/cookoff-admin-11.0
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
fix(submissions): consume flat UserSubmissionResponse[] instead of nested .submission/.resultsĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
fix(users): add target round and role payload to user upgrade endpointCó thể làm lại được @Rithish-2914 đã nhận 54 ngày trước và không có pull request nào đang mở. Đang mởenhancement
CodeChefVIT/cookoff-admin-11.0#22 · 1 người được giao ·
-
fix(leaderboard): align leaderboard API response parsing and podium rankingsCó thể làm lại được @Rithish-2914 đã nhận 54 ngày trước và không có pull request nào đang mở. Đang mởenhancement
CodeChefVIT/cookoff-admin-11.0#19 · 1 người được giao ·
Tất cả issue của CodeChefVIT/cookoff-admin-11.0
Issue tương tự
-
nb stats: the high-error-rate anomaly and the error-causes line give different cause splits for the same errorsCó thể đã có người làm @jeanibarz đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 89/100
jeanibarz/agent-notebook#418 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Page sections overlap each other on every page (e.g. Seasons, Actors and Reviews on show pages)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
josephfung/curia#2563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
README demo: offer a controlled video variant next to the GIF for reduced motion and mobile dataĐang mởaccessibility
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
onetechgroupll/eigen-beam#26 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
maintenance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
killi199/time-tracking#532 ·
Maintainer thường phản hồi trong vòng 1 ngày