diff --git a/server.js b/server.js index f4aa66e..6c28c81 100644 --- a/server.js +++ b/server.js @@ -499,9 +499,6 @@ async function ensureInstance(instanceName) { } -// ========================================== -// 🔗 PORTAL PÚBLICO DEL CLIENTE (BLINDADO SQL) -// ========================================== // ========================================== // 🔗 PORTAL PÚBLICO DEL CLIENTE // ========================================== @@ -515,10 +512,15 @@ app.get("/public/portal/:token", async (req, res) => { const client = qClient.rows[0]; const ownerId = client.owner_id; - const qConfig = await pool.query("SELECT portal_settings FROM users WHERE id = $1", [ownerId]); - const company = qConfig.rows[0]?.portal_settings || { name: "IntegraRepara" }; + // AQUÍ ESTÁ LA CORRECCIÓN: Le pedimos a la BD el nombre y el logo de tu empresa + const qConfig = await pool.query("SELECT full_name, company_logo, portal_settings FROM users WHERE id = $1", [ownerId]); + const userData = qConfig.rows[0] || {}; + + const company = { + name: userData.full_name || "IntegraRepara", + logo: userData.company_logo || null + }; - // AQUÍ ESTÁ LA MAGIA: Hacemos un LEFT JOIN para traernos el nombre y telĂ©fono del tĂ©cnico const qServices = await pool.query(` SELECT s.id, s.service_ref, s.is_urgent, s.raw_data, s.created_at, @@ -547,8 +549,8 @@ app.get("/public/portal/:token", async (req, res) => { is_final: false, scheduled_date: s.raw_data?.scheduled_date || "", scheduled_time: s.raw_data?.scheduled_time || "", - assigned_worker: s.worker_name || null, // Nombre real del tĂ©cnico - worker_phone: s.worker_phone || null, // TelĂ©fono real del tĂ©cnico + assigned_worker: s.worker_name || null, + worker_phone: s.worker_phone || null, raw_data: s.raw_data }; });