Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/(app)/painel/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand Down Expand Up @@ -65,6 +66,8 @@ async function Panel({ searchParams }: Pick<PageProps<"/painel">, "searchParams"
</p>
)}

<UnassignedNotice count={report.unassignedCount} query={query} />

{h.totalEntries === 0 ? (
<p className="rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground">Nenhum registro neste período.</p>
) : (
Expand Down
18 changes: 2 additions & 16 deletions src/app/(app)/relatorios/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand All @@ -42,13 +43,6 @@ async function Reports({ searchParams }: Pick<PageProps<"/relatorios">, "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 });
Expand Down Expand Up @@ -78,15 +72,7 @@ async function Reports({ searchParams }: Pick<PageProps<"/relatorios">, "searchP
</p>
)}

{report.unassignedCount > 0 && (
<p className="rounded-md border bg-muted/50 p-3 text-sm">
{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.{" "}
<Link href={unassignedHref} className="underline">
Ver registros sem projeto
</Link>
</p>
)}
<UnassignedNotice count={report.unassignedCount} query={query} />

{summary.totalEntries === 0 ? (
<p className="rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground">Nenhum registro encontrado com esses filtros.</p>
Expand Down
23 changes: 23 additions & 0 deletions src/app/(app)/relatorios/unassigned-notice.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<p className="rounded-md border bg-muted/50 p-3 text-sm">
{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.{" "}
<Link href={`/relatorios?${params}`} className="underline">
Ver registros sem projeto
</Link>
</p>
);
}
Loading