From 5c801e6a1fe9bb2c3fca501c6a689d61d08f4fe0 Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 4 Mar 2026 15:18:11 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index f8cb439..04a7c1e 100644 --- a/index.html +++ b/index.html @@ -77,10 +77,11 @@ let urlToken = ""; let etasToInit = []; - document.addEventListener("DOMContentLoaded", async () => { + document.addEventListener("DOMContentLoaded", async () => { lucide.createIcons(); const urlParams = new URLSearchParams(window.location.search); urlToken = urlParams.get('token'); + const serviceParam = urlParams.get('service'); // Por si viene el ID del servicio if (!urlToken) { showError(); @@ -88,11 +89,23 @@ } try { - const res = await fetch(`${API_URL}/public/portal/${urlToken}`); + // Le pasamos el token y opcionalmente el ID del servicio si viene en la URL + let fetchUrl = `${API_URL}/public/portal/${urlToken}`; + if (serviceParam) { + fetchUrl += `?service=${serviceParam}`; + } + + const res = await fetch(fetchUrl); const data = await res.json(); + if (!data.ok) throw new Error("Token inválido"); - renderPortal(data.client, data.company, data.services); + + // Si no hay servicios, no mostramos error, mostramos el portal vacío + const servicesList = data.services || []; + + renderPortal(data.client, data.company, servicesList); } catch (e) { + console.error("Error cargando portal:", e); showError(); } });