Files
Investidor-V2/resources/js/components/investment-report-tables.tsx
T

84 lines
3.7 KiB
TypeScript

import {
displayReportMoney,
type InvestmentReportTable,
} from '@/lib/integral-financial-report';
export function InvestmentReportTables({
tables,
}: {
tables: InvestmentReportTable[];
}) {
return (
<div className="space-y-5">
{tables.map((table) => (
<section key={table.id} aria-label={table.title}>
<h4 className="font-semibold">{table.title}</h4>
{table.issues.length > 0 && (
<ul className="list-disc pl-5 text-amber-900">
{[...new Set(table.issues)].map((issue) => (
<li key={issue}>{issue}</li>
))}
</ul>
)}
{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>
);
}