umami/components/pages/event-data/EventDataTable.js

33 lines
882 B
JavaScript
Raw Normal View History

2023-07-10 14:46:45 +02:00
import Link from 'next/link';
import { GridTable, GridColumn } from 'react-basics';
2023-07-10 14:46:45 +02:00
import { useMessages, usePageQuery } from 'hooks';
import Empty from 'components/common/Empty';
2023-07-11 10:16:17 +02:00
export function EventDataTable({ data = [] }) {
const { formatMessage, labels } = useMessages();
2023-07-10 14:46:45 +02:00
const { resolveUrl } = usePageQuery();
if (data.length === 0) {
return <Empty />;
}
return (
<GridTable data={data}>
2023-07-10 14:46:45 +02:00
<GridColumn name="field" label={formatMessage(labels.field)}>
{row => {
return (
<Link href={resolveUrl({ view: row.field })} shallow={true}>
{row.field}
</Link>
);
}}
</GridColumn>
<GridColumn name="total" label={formatMessage(labels.totalRecords)}>
{({ total }) => total.toLocaleString()}
</GridColumn>
</GridTable>
);
}
export default EventDataTable;