From c6227150a3ff668627e2acc2fcb8d14f37aa23f1 Mon Sep 17 00:00:00 2001 From: Lizandro GD Date: Mon, 3 Aug 2026 01:00:56 +0000 Subject: [PATCH] fix: evitar spinner de carga infinito si falla la API en plantillas/tarifas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit loadData() no tenía try/catch: si la petición fallaba (deploy sin el código nuevo, tabla inexistente, etc.) el estado "loading" nunca volvía a false y la pantalla quedaba trabada en el overlay de carga sin ningún mensaje de error. Co-Authored-By: Claude Sonnet 5 --- .../views/automatizacion/plantillas_documento.html | 12 ++++++++---- resources/views/automatizacion/tarifas.html | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/resources/views/automatizacion/plantillas_documento.html b/resources/views/automatizacion/plantillas_documento.html index 2c8dd29..db5e901 100644 --- a/resources/views/automatizacion/plantillas_documento.html +++ b/resources/views/automatizacion/plantillas_documento.html @@ -161,10 +161,14 @@ document.addEventListener('alpine:init', () => { async loadData() { this.loading = true; - const { data } = await axios.get(`/app/api/plantillas-documento?page=${this.page}&limit=${this.limit}&tipo=${this.filtroTipo}`); - this.datos = data.registros || []; - this.total = data.total || 0; - this.totalPages = data.totalPages || 1; + try { + const { data } = await axios.get(`/app/api/plantillas-documento?page=${this.page}&limit=${this.limit}&tipo=${this.filtroTipo}`); + this.datos = data.registros || []; + this.total = data.total || 0; + this.totalPages = data.totalPages || 1; + } catch(e) { + this.showToast(e.response?.data?.error || 'No se pudo cargar la lista', 'error'); + } this.loading = false; }, diff --git a/resources/views/automatizacion/tarifas.html b/resources/views/automatizacion/tarifas.html index d9b785d..9b5eff9 100644 --- a/resources/views/automatizacion/tarifas.html +++ b/resources/views/automatizacion/tarifas.html @@ -160,10 +160,14 @@ document.addEventListener('alpine:init', () => { async loadData() { this.loading = true; - const { data } = await axios.get(`/app/api/tarifas?page=${this.page}&limit=${this.limit}&search=${this.search}`); - this.datos = data.registros || []; - this.total = data.total || 0; - this.totalPages = data.totalPages || 1; + try { + const { data } = await axios.get(`/app/api/tarifas?page=${this.page}&limit=${this.limit}&search=${this.search}`); + this.datos = data.registros || []; + this.total = data.total || 0; + this.totalPages = data.totalPages || 1; + } catch(e) { + this.showToast(e.response?.data?.error || 'No se pudo cargar la lista', 'error'); + } this.loading = false; },