Actualizar index.html
This commit is contained in:
17
index.html
17
index.html
@@ -81,6 +81,7 @@
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user