103 lines
4.5 KiB
TypeScript
103 lines
4.5 KiB
TypeScript
import {
|
|
displayReportMoney,
|
|
type InvestmentReportTable,
|
|
} from '@/lib/integral-financial-report';
|
|
import { financialIssuesForDisplay } from '@/lib/financial-issue-presentation';
|
|
|
|
export function InvestmentReportTables({
|
|
tables,
|
|
}: {
|
|
tables: InvestmentReportTable[];
|
|
}) {
|
|
const issues = financialIssuesForDisplay(tables);
|
|
return (
|
|
<div className="space-y-5">
|
|
{issues.length > 0 && (
|
|
<aside
|
|
aria-label="Dados financeiros a corrigir"
|
|
className="space-y-2 rounded border border-amber-400 bg-amber-50 p-3 text-sm"
|
|
>
|
|
<h4 className="font-semibold">
|
|
Confira os dados de origem
|
|
</h4>
|
|
<ul className="list-disc space-y-2 pl-5">
|
|
{issues.map((issue) => (
|
|
<li
|
|
key={issue.message}
|
|
data-correction-message={issue.message}
|
|
>
|
|
<p>{issue.message}</p>
|
|
<p className="text-xs">
|
|
Tabelas afectadas: {issue.tables.join('; ')}
|
|
.
|
|
</p>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</aside>
|
|
)}
|
|
{tables.map((table) => (
|
|
<section key={table.id} aria-label={table.title}>
|
|
<h4 className="font-semibold">{table.title}</h4>
|
|
{table.rows.length > 0 && (
|
|
<div
|
|
className="overflow-x-auto"
|
|
tabIndex={0}
|
|
role="region"
|
|
aria-label={`Tabela ${table.title}`}
|
|
>
|
|
<table className="w-full border-collapse text-left text-sm">
|
|
<caption className="sr-only">
|
|
{table.title}
|
|
</caption>
|
|
<thead>
|
|
<tr>
|
|
{table.headers.map((header, index) => (
|
|
<th
|
|
className="min-w-28 border p-2"
|
|
key={index}
|
|
>
|
|
{header}
|
|
</th>
|
|
))}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{table.rows.map((row, i) => (
|
|
<tr key={i}>
|
|
{row.map((cell, j) =>
|
|
j === 0 ? (
|
|
<th
|
|
className="min-w-40 border p-2 font-medium"
|
|
key={j}
|
|
>
|
|
{cell}
|
|
</th>
|
|
) : (
|
|
<td
|
|
className="border p-2 whitespace-nowrap"
|
|
key={j}
|
|
>
|
|
{displayReportMoney(
|
|
cell,
|
|
)}
|
|
</td>
|
|
),
|
|
)}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)}
|
|
{table.notes.map((note, i) => (
|
|
<p className="mt-1 text-sm" key={i}>
|
|
{note}
|
|
</p>
|
|
))}
|
|
</section>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|