import React from "react"; import type { ComparisonRowData } from "../scenarios/types"; interface ComparisonTableProps { headers?: string[]; rows?: ComparisonRowData[]; } export const ComparisonTable: React.FC = ({ headers, rows, }) => { if (!rows || rows.length === 0) return null; const hasCashColumn = rows.some((r) => r.cashValue !== undefined); const defaultHeaders = hasCashColumn ? ["Tiêu chí", "Điểm A (Gốc)", "Điểm B (Hiện tại)", "Điểm C (Tiền mặt)", "Ghi chú"] : ["Tiêu chí", "Điểm A (Gốc)", "Điểm B (Hiện tại)", "Ghi chú"]; const actualHeaders = headers && headers.length > 0 ? headers : defaultHeaders; return (

Bảng đối sánh các trạng thái cân bằng

{actualHeaders.map((head, idx) => ( ))} {rows.map((row, idx) => ( {hasCashColumn && ( )} {row.note !== undefined && ( )} ))}
{head}
{row.criterion} {row.baseValue} {row.currentValue} {row.cashValue ?? ""} {row.note}
); };