From e72923ec8630dfde95be82c0728817f05e7f5197 Mon Sep 17 00:00:00 2001 From: soufiane Date: Wed, 19 Nov 2025 14:30:44 +0100 Subject: [PATCH] fix: transform pending tickets data to match frontend expectations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the getPendingTickets endpoint to return nested objects for user and prize data instead of flat SQL columns. Frontend expects structure like ticket.user.firstName and ticket.prize.name, which now displays correctly in the employee verification interface instead of showing N/A. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/controllers/employee.controller.js | 32 +++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/controllers/employee.controller.js b/src/controllers/employee.controller.js index e293bae8..bddaffdf 100644 --- a/src/controllers/employee.controller.js +++ b/src/controllers/employee.controller.js @@ -18,12 +18,16 @@ export const getPendingTickets = asyncHandler(async (req, res) => { t.code, t.status, t.played_at, + u.id as user_id, u.email as user_email, - u.first_name || ' ' || u.last_name as user_name, + u.first_name as user_first_name, + u.last_name as user_last_name, u.phone as user_phone, + p.id as prize_id, p.name as prize_name, p.type as prize_type, - p.value as prize_value + p.value as prize_value, + p.description as prize_description FROM tickets t JOIN users u ON t.user_id = u.id JOIN prizes p ON t.prize_id = p.id @@ -41,9 +45,31 @@ export const getPendingTickets = asyncHandler(async (req, res) => { const total = parseInt(countResult.rows[0].count); + // Transform data to match frontend expectations + const transformedData = result.rows.map(row => ({ + id: row.id, + code: row.code, + status: row.status, + playedAt: row.played_at, + user: { + id: row.user_id, + email: row.user_email, + firstName: row.user_first_name, + lastName: row.user_last_name, + phone: row.user_phone, + }, + prize: { + id: row.prize_id, + name: row.prize_name, + type: row.prize_type, + value: row.prize_value, + description: row.prize_description, + }, + })); + res.json({ success: true, - data: result.rows, + data: transformedData, pagination: { total, page: parseInt(page),