2023-07-10 14:46:45 +02:00
|
|
|
import Link from 'next/link';
|
2023-07-10 13:35:19 +02:00
|
|
|
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-10 13:35:19 +02:00
|
|
|
|
2023-07-11 10:16:17 +02:00
|
|
|
export function EventDataTable({ data = [] }) {
|
2023-07-10 13:35:19 +02:00
|
|
|
const { formatMessage, labels } = useMessages();
|
2023-07-10 14:46:45 +02:00
|
|
|
const { resolveUrl } = usePageQuery();
|
|
|
|
|
2023-07-14 16:58:15 +02:00
|
|
|
function linkToView(row, cell) {
|
|
|
|
return (
|
|
|
|
<Link href={resolveUrl({ view: row.field, event: row.event })} shallow={true}>
|
|
|
|
{cell}
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-07-10 14:46:45 +02:00
|
|
|
if (data.length === 0) {
|
|
|
|
return <Empty />;
|
|
|
|
}
|
2023-07-10 13:35:19 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<GridTable data={data}>
|
2023-07-14 16:58:15 +02:00
|
|
|
<GridColumn name="event" label={formatMessage(labels.event)}>
|
|
|
|
{row => linkToView(row, row.event)}
|
|
|
|
</GridColumn>
|
2023-07-10 14:46:45 +02:00
|
|
|
<GridColumn name="field" label={formatMessage(labels.field)}>
|
2023-07-14 16:58:15 +02:00
|
|
|
{row => linkToView(row, row.field)}
|
2023-07-10 14:46:45 +02:00
|
|
|
</GridColumn>
|
|
|
|
<GridColumn name="total" label={formatMessage(labels.totalRecords)}>
|
2023-07-10 13:35:19 +02:00
|
|
|
{({ total }) => total.toLocaleString()}
|
|
|
|
</GridColumn>
|
|
|
|
</GridTable>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default EventDataTable;
|