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),