import * as React from 'react' import { Link, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableCellProps, } from '@mui/material' import { useTheme } from '@mui/material/styles' import { Tooltip } from '@nymproject/react/tooltip/Tooltip' import { CopyToClipboard } from '@nymproject/react/clipboard/CopyToClipboard' import { Box } from '@mui/system' import { unymToNym } from '@/app/utils/currency' import { GatewayEnrichedRowType } from './Gateways/Gateways' import { MixnodeRowType } from './MixNodes' import { StakeSaturationProgressBar } from './MixNodes/Economics/StakeSaturationProgressBar' export type ColumnsType = { field: string title: string headerAlign?: TableCellProps['align'] width?: string | number tooltipInfo?: string } export interface UniversalTableProps { tableName: string columnsData: ColumnsType[] rows: T[] } function formatCellValues(val: string | number, field: string) { if (field === 'identity_key' && typeof val === 'string') { return ( {val} ) } if (field === 'bond') { return unymToNym(val, 6) } if (field === 'owner') { return ( {val} ) } if (field === 'stake_saturation') { return } return val } export const DetailTable: FCWithChildren<{ tableName: string columnsData: ColumnsType[] rows: MixnodeRowType[] | GatewayEnrichedRowType[] }> = ({ tableName, columnsData, rows }: UniversalTableProps) => { const theme = useTheme() return ( {columnsData?.map(({ field, title, width, tooltipInfo }) => ( {tooltipInfo && ( )} {title} ))} {rows.map((eachRow) => ( {columnsData?.map((data, index) => ( {formatCellValues( eachRow[columnsData[index].field], columnsData[index].field )} ))} ))}
) }