Files
jorgecuadros-platform/apps/web/src/components/ContextReports.tsx
T
rmancinas 8802f08d4f
Build and Push Images / Build jorgecuadros-web (push) Successful in 1m35s
Build and Push Images / Build jorgecuadros-api (push) Successful in 2m11s
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.
2026-07-23 23:20:41 -07:00

58 lines
1.7 KiB
TypeScript

"use client";
import Link from "next/link";
/**
* The context-report shortcut. One row of pill buttons that link to
* pre-filtered /reportes/[slug] pages. Used in the page header of
* domain pages (clientes, polizas, servicios, estado-cuenta, banco).
*
* `entries` accepts both static links (slug + label) and pre-filtered
* links (slug + params object). Pre-filtered ones build the query
* string automatically; the runner pre-fills the form.
*/
export interface ReportLink {
slug: string;
label: string;
/** Optional pre-fill for the report's filter form. */
params?: Record<string, string>;
/** When true, opens the report in a new tab (for "see the catalog"
* style entries where the user is going to look around). */
external?: boolean;
}
export function ContextReports({
label = "Reportes",
entries,
}: {
label?: string;
entries: ReportLink[];
}) {
if (entries.length === 0) return null;
return (
<div className="context-reports" aria-label={label}>
<span className="context-reports-label">{label}</span>
{entries.map((e) => {
const qs = e.params
? "?" +
new URLSearchParams(
Object.entries(e.params).filter(([, v]) => v != null && v !== ""),
).toString()
: "";
const href = `/reportes/${e.slug}${qs}`;
return (
<Link
key={`${e.slug}-${JSON.stringify(e.params ?? {})}`}
href={href}
className="context-report-link"
target={e.external ? "_blank" : undefined}
rel={e.external ? "noopener" : undefined}
>
{e.label}
</Link>
);
})}
</div>
);
}