1
0
mirror of https://github.com/kremalicious/umami.git synced 2025-02-14 21:10:34 +01:00
umami/components/pages/reports/insights/InsightsTable.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-07-08 05:38:43 +02:00
import { useContext } from 'react';
import { GridTable, GridColumn } from 'react-basics';
import { useFormat, useMessages } from 'hooks';
2023-07-08 05:38:43 +02:00
import { ReportContext } from '../Report';
export function InsightsTable() {
const { report } = useContext(ReportContext);
const { formatMessage, labels } = useMessages();
2023-08-07 07:52:17 +02:00
const { groups = [] } = report?.parameters || {};
const { formatValue } = useFormat();
2023-07-08 05:38:43 +02:00
return (
<GridTable data={report?.data || []}>
2023-08-07 07:52:17 +02:00
{groups.map(({ name, label }) => {
return (
<GridColumn key={name} name={name} label={label}>
{row => formatValue(row[name], name)}
</GridColumn>
);
2023-08-03 19:44:35 +02:00
})}
<GridColumn name="views" label={formatMessage(labels.views)} width="100px">
{row => row.views.toLocaleString()}
</GridColumn>
<GridColumn name="visitors" label={formatMessage(labels.visitors)} width="100px">
{row => row.views.toLocaleString()}
</GridColumn>
2023-07-08 05:38:43 +02:00
</GridTable>
);
}
export default InsightsTable;