Rapport_React/src/views/ivareport/KamWise.jsx

36 lines
1.2 KiB
JavaScript

import { formatNumber } from './helpers';
export default function KamWise({ table }) {
const columns = table.brandColumns;
return (
<table className="table table-centered table-nowrap mb-0 iva-report-table">
<thead>
<tr>
<th className="sticky-first-col iva-th-id">Territory</th>
<th className="iva-th-id">KAM Name</th>
<th className="iva-th-metric">Total Brand POB Val</th>
{columns.map((col) => (
<th key={col.key} className="iva-th-metric">{col.key}</th>
))}
</tr>
</thead>
<tbody>
{table.rows.length ? table.rows.map((row, rowIndex) => (
<tr key={rowIndex}>
<td className="sticky-first-col">{row.territory}</td>
<td>{row.kamName}</td>
<td>{formatNumber(row.total ?? 0)}</td>
{columns.map((col) => (
<td key={col.key}>{formatNumber(row.values[col.key] ?? 0)}</td>
))}
</tr>
)) : (
<tr>
<td colSpan={Math.max(1, 3 + columns.length)} className="text-center text-muted py-3">No data</td>
</tr>
)}
</tbody>
</table>
);
}