fix(dashboards): guard convex query and refine empty state CTA
This commit is contained in:
parent
fb17882dad
commit
38651ca706
2 changed files with 8 additions and 3 deletions
|
|
@ -462,10 +462,11 @@ export function DashboardBuilder({ dashboardId, editable = true, mode = "edit" }
|
||||||
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
const tenantId = session?.user.tenantId ?? DEFAULT_TENANT_ID
|
||||||
const viewerId = convexUserId as Id<"users"> | null
|
const viewerId = convexUserId as Id<"users"> | null
|
||||||
const canEdit = editable && Boolean(viewerId) && isStaff
|
const canEdit = editable && Boolean(viewerId) && isStaff
|
||||||
|
const hasDashboardId = typeof dashboardId === "string" && dashboardId.length > 0
|
||||||
|
|
||||||
const detail = useQuery(
|
const detail = useQuery(
|
||||||
api.dashboards.get,
|
api.dashboards.get,
|
||||||
viewerId
|
viewerId && hasDashboardId
|
||||||
? ({
|
? ({
|
||||||
tenantId,
|
tenantId,
|
||||||
viewerId: viewerId as Id<"users">,
|
viewerId: viewerId as Id<"users">,
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,10 @@ export function DashboardListView() {
|
||||||
|
|
||||||
const activeDashboards = dashboards.filter((dashboard) => !dashboard.isArchived)
|
const activeDashboards = dashboards.filter((dashboard) => !dashboard.isArchived)
|
||||||
|
|
||||||
|
const renderCreateButton = () => (
|
||||||
|
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
|
@ -208,7 +212,7 @@ export function DashboardListView() {
|
||||||
Combine KPIs, gráficos, tabelas e texto em painéis dinâmicos com filtros globais.
|
Combine KPIs, gráficos, tabelas e texto em painéis dinâmicos com filtros globais.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
{activeDashboards.length > 0 ? renderCreateButton() : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeDashboards.length === 0 ? (
|
{activeDashboards.length === 0 ? (
|
||||||
|
|
@ -223,7 +227,7 @@ export function DashboardListView() {
|
||||||
Monte painéis por cliente, fila ou operação e compartilhe com a equipe.
|
Monte painéis por cliente, fila ou operação e compartilhe com a equipe.
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
{renderCreateButton()}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-2 text-sm text-muted-foreground">
|
<CardContent className="space-y-2 text-sm text-muted-foreground">
|
||||||
<p>• Arraste e redimensione widgets livremente no canvas.</p>
|
<p>• Arraste e redimensione widgets livremente no canvas.</p>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue