/** * RowViewer component - Display current row data with issue highlighting */ import React from 'react'; import { Box, Typography, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Chip, LinearProgress, } from '@mui/material'; import { Warning as WarningIcon, CheckCircle as CleanIcon, } from '@mui/icons-material'; interface RowViewerProps { rowData: Record; rowIndex: number; totalRows: number; issues?: string[]; changedColumns?: Record; } const RowViewer: React.FC = ({ rowData, rowIndex, totalRows, issues = [], changedColumns = {}, }) => { const columns = Object.keys(rowData); const progress = totalRows > 0 ? ((rowIndex + 1) / totalRows) * 100 : 0; const getValueType = (value: unknown): string => { if (value === null || value === undefined) return 'null'; if (typeof value === 'number') return Number.isInteger(value) ? 'int' : 'float'; if (typeof value === 'boolean') return 'bool'; if (typeof value === 'string') return 'string'; return typeof value; }; const hasIssue = (column: string): boolean => { return issues.some((issue) => issue.toLowerCase().includes(column.toLowerCase())); }; const isChanged = (column: string): boolean => { return column in changedColumns; }; return ( {/* Header */} Row {rowIndex + 1} of {totalRows} {issues.length > 0 ? ( {issues.length} issue{issues.length !== 1 ? 's' : ''} detected ) : ( No issues detected )} {/* Progress Bar */} {/* Data Table */} Column Type Value Status {columns.map((column) => { const value = rowData[column]; const issue = hasIssue(column); const changed = isChanged(column); const changeInfo = changedColumns[column]; return ( {column} {changed && changeInfo && ( {String(changeInfo.before)} )} {value === null || value === undefined ? ( null ) : ( String(value) )} {issue && ( } label="Issue" color="error" size="small" variant="outlined" /> )} {changed && ( } label="Modified" color="success" size="small" variant="outlined" /> )} {!issue && !changed && ( } label="Clean" color="success" size="small" variant="outlined" /> )} ); })}
{/* Legend */} Has Issue Modified Clean ); }; export default RowViewer;