From 38651ca706ec654defbef18e3e6bce4d936ce7a5 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Wed, 5 Nov 2025 19:43:36 -0300 Subject: [PATCH] fix(dashboards): guard convex query and refine empty state CTA --- src/components/dashboards/dashboard-builder.tsx | 3 ++- src/components/dashboards/dashboard-list.tsx | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/dashboards/dashboard-builder.tsx b/src/components/dashboards/dashboard-builder.tsx index 063067b..6319298 100644 --- a/src/components/dashboards/dashboard-builder.tsx +++ b/src/components/dashboards/dashboard-builder.tsx @@ -462,10 +462,11 @@ export function DashboardBuilder({ dashboardId, editable = true, mode = "edit" } const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID const viewerId = convexUserId as Id<"users"> | null const canEdit = editable && Boolean(viewerId) && isStaff + const hasDashboardId = typeof dashboardId === "string" && dashboardId.length > 0 const detail = useQuery( api.dashboards.get, - viewerId + viewerId && hasDashboardId ? ({ tenantId, viewerId: viewerId as Id<"users">, diff --git a/src/components/dashboards/dashboard-list.tsx b/src/components/dashboards/dashboard-list.tsx index e1d0258..6ae934a 100644 --- a/src/components/dashboards/dashboard-list.tsx +++ b/src/components/dashboards/dashboard-list.tsx @@ -199,6 +199,10 @@ export function DashboardListView() { const activeDashboards = dashboards.filter((dashboard) => !dashboard.isArchived) + const renderCreateButton = () => ( + + ) + return (
@@ -208,7 +212,7 @@ export function DashboardListView() { Combine KPIs, gráficos, tabelas e texto em painéis dinâmicos com filtros globais.

- + {activeDashboards.length > 0 ? renderCreateButton() : null}
{activeDashboards.length === 0 ? ( @@ -223,7 +227,7 @@ export function DashboardListView() { Monte painéis por cliente, fila ou operação e compartilhe com a equipe. - + {renderCreateButton()}

• Arraste e redimensione widgets livremente no canvas.