From a191ec8bddf8e8be05e0e7f4622a35607c904118 Mon Sep 17 00:00:00 2001 From: Vinicius Garcia Date: Thu, 8 Oct 2026 15:12:56 +0000 Subject: [PATCH] feat(dashboard): aviso de registros sem projeto tambem no painel --- src/app/(app)/painel/page.tsx | 3 +++ src/app/(app)/relatorios/page.tsx | 18 ++------------- .../(app)/relatorios/unassigned-notice.tsx | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 src/app/(app)/relatorios/unassigned-notice.tsx diff --git a/src/app/(app)/painel/page.tsx b/src/app/(app)/painel/page.tsx index b2fcfd9..cee5d42 100644 --- a/src/app/(app)/painel/page.tsx +++ b/src/app/(app)/painel/page.tsx @@ -14,6 +14,7 @@ import { loadCatalog } from "../views"; import { ReportChartsSection } from "../relatorios/charts"; import { loadReport } from "../relatorios/load-report"; import { ReportFilters } from "../relatorios/report-filters"; +import { UnassignedNotice } from "../relatorios/unassigned-notice"; export const metadata: Metadata = { title: "Painel" }; @@ -65,6 +66,8 @@ async function Panel({ searchParams }: Pick, "searchParams"

)} + + {h.totalEntries === 0 ? (

Nenhum registro neste período.

) : ( diff --git a/src/app/(app)/relatorios/page.tsx b/src/app/(app)/relatorios/page.tsx index ef7495a..4107c7f 100644 --- a/src/app/(app)/relatorios/page.tsx +++ b/src/app/(app)/relatorios/page.tsx @@ -17,6 +17,7 @@ import { loadCatalog, reportRowToEntryView } from "../views"; import { DayMatrixCard } from "./day-matrix"; import { loadReport } from "./load-report"; import { ReportFilters } from "./report-filters"; +import { UnassignedNotice } from "./unassigned-notice"; export const metadata: Metadata = { title: "Relatórios" }; @@ -42,13 +43,6 @@ async function Reports({ searchParams }: Pick, "searchP params.set("formato", format); return `/relatorios/export?${params}`; }; - const unassignedHref = (() => { - const params = new URLSearchParams({ periodo: query.periodo, projeto: "none" }); - if (query.de) params.set("de", query.de); - if (query.ate) params.set("ate", query.ate); - for (const id of query.pessoas) params.append("pessoas", id); - return `/relatorios?${params}`; - })(); const panelHref = `/painel?${toSearchParams(query)}`; const summary = summarize(result.rows, query.agrupar); const dayMatrix = buildDayMatrix(result.rows, period, tz, { includePeople: isAdmin }); @@ -78,15 +72,7 @@ async function Reports({ searchParams }: Pick, "searchP

)} - {report.unassignedCount > 0 && ( -

- {report.unassignedCount === 1 ? "1 registro sem projeto neste período não entra" : `${report.unassignedCount} registros sem projeto neste período não entram`}{" "} - no filtro de cliente.{" "} - - Ver registros sem projeto - -

- )} + {summary.totalEntries === 0 ? (

Nenhum registro encontrado com esses filtros.

diff --git a/src/app/(app)/relatorios/unassigned-notice.tsx b/src/app/(app)/relatorios/unassigned-notice.tsx new file mode 100644 index 0000000..96a3b81 --- /dev/null +++ b/src/app/(app)/relatorios/unassigned-notice.tsx @@ -0,0 +1,23 @@ +import Link from "next/link"; +import type { ReportQuery } from "@/lib/schemas/report"; + +/** + * Entries without a project cannot match a client filter, so they drop out of the numbers. Say so, with a link + * that lists them (same period and people) in the report. `count` is 0 unless a client filter is hiding them. + */ +export function UnassignedNotice({ count, query }: { count: number; query: ReportQuery }) { + if (count <= 0) return null; + const params = new URLSearchParams({ periodo: query.periodo, projeto: "none" }); + if (query.de) params.set("de", query.de); + if (query.ate) params.set("ate", query.ate); + for (const id of query.pessoas) params.append("pessoas", id); + + return ( +

+ {count === 1 ? "1 registro sem projeto neste período não entra" : `${count} registros sem projeto neste período não entram`} no filtro de cliente.{" "} + + Ver registros sem projeto + +

+ ); +}