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 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">,
|
||||
|
|
|
|||
|
|
@ -199,6 +199,10 @@ export function DashboardListView() {
|
|||
|
||||
const activeDashboards = dashboards.filter((dashboard) => !dashboard.isArchived)
|
||||
|
||||
const renderCreateButton = () => (
|
||||
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<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.
|
||||
</p>
|
||||
</div>
|
||||
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
||||
{activeDashboards.length > 0 ? renderCreateButton() : null}
|
||||
</div>
|
||||
|
||||
{activeDashboards.length === 0 ? (
|
||||
|
|
@ -223,7 +227,7 @@ export function DashboardListView() {
|
|||
Monte painéis por cliente, fila ou operação e compartilhe com a equipe.
|
||||
</CardDescription>
|
||||
</div>
|
||||
<CreateDashboardDialog onCreate={handleCreate} isLoading={isCreating} />
|
||||
{renderCreateButton()}
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2 text-sm text-muted-foreground">
|
||||
<p>• Arraste e redimensione widgets livremente no canvas.</p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue