'use client' import type { TableArtifact } from '@/types/chat' interface ChatDataTableProps { artifact: TableArtifact } function formatCell(value: string | number, align?: 'left' | 'right'): string { if (typeof value === 'number') { return new Intl.NumberFormat('sv-SE', { minimumFractionDigits: value % 1 !== 0 ? 2 : 0, maximumFractionDigits: 2, }).format(value) } return String(value) } export function ChatDataTable({ artifact }: ChatDataTableProps) { const { title, columns, rows, summary_row } = artifact return (

{title}

{columns.map((col) => ( ))} {rows.map((row, i) => ( {columns.map((col) => ( ))} ))} {summary_row && ( {columns.map((col) => ( ))} )}
{col.label}
{formatCell(row[col.key], col.align)}
{summary_row[col.key] !== undefined ? formatCell(summary_row[col.key], col.align) : ''}
) }