'Unauthorized']); exit; } // Include agent functions require_once 'agent-functions.php'; if (isset($_GET['id'])) { $agentId = intval($_GET['id']); $agent = getAgentDetails($agentId); if ($agent) { header('Content-Type: application/json'); echo json_encode($agent); } else { // Return dummy data for testing $dummyAgent = [ 'id' => $agentId, 'full_name' => 'Test Agent ' . $agentId, 'phone' => '+254 7XX XXX XXX', 'location' => 'Nairobi', 'applied_at' => date('Y-m-d H:i:s'), 'id_front' => '#', 'id_back' => '#' ]; header('Content-Type: application/json'); echo json_encode($dummyAgent); } } else { header('HTTP/1.1 400 Bad Request'); echo json_encode(['error' => 'Agent ID required']); } ?>