From eb9544860426d992ea88bfac921eb56f597eaef0 Mon Sep 17 00:00:00 2001
From: killer-cf
Date: Wed, 19 Nov 2025 16:23:01 -0300
Subject: [PATCH] refactor: streamline dashboard page and improve error
handling
- Removed unnecessary refresh logic for monitoring queries to enhance performance.
- Updated error handling to ensure proper type casting and improved URL management.
- Simplified the rendering of components and improved the overall structure for better readability.
- Added a user-friendly error message for cases when dashboard data fails to load.
---
apps/web/src/routes/(dashboard)/+page.svelte | 36 ++++++++++----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/apps/web/src/routes/(dashboard)/+page.svelte b/apps/web/src/routes/(dashboard)/+page.svelte
index df2a64f..8b135c9 100644
--- a/apps/web/src/routes/(dashboard)/+page.svelte
+++ b/apps/web/src/routes/(dashboard)/+page.svelte
@@ -32,9 +32,6 @@
>(null);
let redirectRoute = $state("");
- // Forçar atualização das queries de monitoramento a cada 1 segundo
- let refreshKey = $state(0);
-
// Limpar URL após navegação estar completa
afterNavigate(({ to }) => {
if (to?.url.searchParams.has("error")) {
@@ -42,7 +39,7 @@
const route = to.url.searchParams.get("route") || to.url.searchParams.get("redirect") || "";
if (error) {
- alertType = error as any;
+ alertType = error as typeof alertType;
redirectRoute = route;
showAlert = true;
@@ -53,10 +50,12 @@
// Limpar URL usando SvelteKit (após router estar inicializado)
try {
- replaceState(to.url.pathname, {});
- } catch (e) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ replaceState(resolve(to.url.pathname as any), {});
+ } catch {
// Se ainda não estiver pronto, usar goto com replaceState
- goto(to.url.pathname, { replaceState: true, noScroll: true });
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ goto(resolve(to.url.pathname as any), { replaceState: true, noScroll: true });
}
// Auto-fechar após 10 segundos
@@ -68,8 +67,6 @@
});
onMount(() => {
- mounted = true;
-
// Verificar se há erro na URL ao carregar a página
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has("error")) {
@@ -81,10 +78,9 @@
}
}
- // Atualizar relógio e forçar refresh das queries a cada segundo
+ // Atualizar relógio a cada segundo
const interval = setInterval(() => {
currentTime = new Date();
- refreshKey = (refreshKey + 1) % 1000; // Incrementar para forçar re-render
}, 1000);
return () => clearInterval(interval);
@@ -163,15 +159,14 @@
{#if alertType === "access_denied"}
@@ -207,7 +202,7 @@
month: "long",
day: "numeric",
})}
- {" - "}
+ -
{currentTime.toLocaleTimeString("pt-BR")}
@@ -606,7 +601,7 @@
- {#each [10, 8, 6, 4, 2, 0] as val}
+ {#each [10, 8, 6, 4, 2, 0] as val (val)}
{val}
{/each}
@@ -614,7 +609,7 @@
- {#each Array.from({ length: 6 }) as _, i}
+ {#each [0, 1, 2, 3, 4, 5] as i (i)}
- {#each atividade.historico as ponto, idx}
+ {#each atividade.historico as ponto, idx (idx)}
+ {:else}
+
+
+ Não foi possível carregar os dados do dashboard.
+
{/if}