2023-07-11 19:54:57 +00:00
|
|
|
import { Percentile } from '../../constants/percentiles';
|
|
|
|
|
import GenericStatsColumn from './components/GenericStatsColumn';
|
2023-05-24 02:01:22 +00:00
|
|
|
|
2023-06-01 19:16:29 +00:00
|
|
|
export type Stat =
|
2023-06-02 01:31:14 +00:00
|
|
|
| [string, string | number | undefined]
|
|
|
|
|
| [string, string | number | undefined, Percentile | undefined];
|
2023-05-24 02:01:22 +00:00
|
|
|
|
2023-05-28 02:25:59 +00:00
|
|
|
export interface GenericStatsProps {
|
|
|
|
|
stats: Stat[];
|
|
|
|
|
columnCount?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function GenericStats({
|
|
|
|
|
stats,
|
|
|
|
|
columnCount = 2,
|
|
|
|
|
}: GenericStatsProps) {
|
2023-06-02 01:31:14 +00:00
|
|
|
const filteredStats = stats.filter(([, value]) => value !== undefined);
|
2023-05-29 17:12:05 +00:00
|
|
|
const itemsPerRow = Math.ceil(filteredStats.length / columnCount);
|
2023-05-24 02:01:22 +00:00
|
|
|
const columns: Stat[][] = [];
|
|
|
|
|
|
2023-05-29 17:12:05 +00:00
|
|
|
filteredStats.forEach((stat, index) => {
|
2023-05-24 02:01:22 +00:00
|
|
|
const column = Math.floor(index / itemsPerRow);
|
|
|
|
|
if (!columns[column]) columns[column] = [];
|
|
|
|
|
columns[column].push(stat);
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-28 02:25:59 +00:00
|
|
|
return (
|
|
|
|
|
<div style={{ display: 'flex', gap: 32 }}>
|
|
|
|
|
{columns.map((stats) => (
|
|
|
|
|
<GenericStatsColumn
|
|
|
|
|
key={stats.map((stat) => stat[0]).join('-')}
|
|
|
|
|
stats={stats}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
2023-05-24 02:01:22 +00:00
|
|
|
</div>
|
2023-05-28 02:25:59 +00:00
|
|
|
);
|
2023-05-24 02:01:22 +00:00
|
|
|
}
|