feat(reports): reports module + /inicio + edo-cuenta-datos prefill
- New reports backend (registry, service, controller, outputs, types) with catalog endpoint + slug/CSV/XLSX/PDF/print outputs. - /reportes catalog + /reportes/[slug] runner; ReportRunner + ContextReports components wire pre-filtered links from domain pages. - Fix: /reportes/[slug] now reads searchParams and forwards initialParams to ReportRunner so /reportes/edo-cuenta-datos?customerId=... auto-runs instead of dropping the id and forcing a manual customer search. - /inicio landing page; root + login redirect to /inicio. - Company header env vars + logo asset for PDF/print rendering. - exceljs + pdfkit deps.
This commit is contained in:
@@ -44,6 +44,8 @@ import type {
|
||||
PropertyListResponse,
|
||||
PropertySort,
|
||||
PropertyStats,
|
||||
ReportCatalog,
|
||||
ReportRunResult,
|
||||
ServiceInput,
|
||||
TrustInput,
|
||||
Role,
|
||||
@@ -730,3 +732,37 @@ export function startOpsJob(kind: OpsJobKind, file?: string): Promise<OpsJob> {
|
||||
body: JSON.stringify({ kind, file }),
|
||||
});
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- Reports module */
|
||||
|
||||
export function getReportCatalog(): Promise<ReportCatalog> {
|
||||
return apiFetch<ReportCatalog>("/reports");
|
||||
}
|
||||
|
||||
export function runReport(
|
||||
slug: string,
|
||||
params: Record<string, string | undefined>,
|
||||
): Promise<ReportRunResult> {
|
||||
const qs = new URLSearchParams();
|
||||
for (const [k, v] of Object.entries(params)) {
|
||||
if (v != null && v !== "") qs.set(k, v);
|
||||
}
|
||||
const tail = qs.toString();
|
||||
return apiFetch<ReportRunResult>(`/reports/${slug}${tail ? `?${tail}` : ""}`);
|
||||
}
|
||||
|
||||
/** Build a download URL for a report's file output. The session cookie
|
||||
* travels with the browser's same-origin navigation, so a plain `href`
|
||||
* is enough — no fetch-with-credentials dance. */
|
||||
export function reportDownloadUrl(
|
||||
slug: string,
|
||||
format: "csv" | "xlsx" | "pdf" | "print",
|
||||
params: Record<string, string | undefined>,
|
||||
): string {
|
||||
const qs = new URLSearchParams();
|
||||
for (const [k, v] of Object.entries(params)) {
|
||||
if (v != null && v !== "") qs.set(k, v);
|
||||
}
|
||||
const tail = qs.toString();
|
||||
return `${API_ORIGIN}/reports/${slug}/${format}${tail ? `?${tail}` : ""}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user