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();
}
});