mirror of
https://github.com/umami-software/umami.git
synced 2026-02-22 05:25:36 +01:00
Refactor part 2: Electric Boogaloo. Standardize way of passing filter parameters.
This commit is contained in:
parent
f26f1b0581
commit
cdf391d5c2
90 changed files with 867 additions and 709 deletions
|
|
@ -1,7 +1,9 @@
|
|||
import { useWebsiteEventsQuery } from '@/components/hooks';
|
||||
import { useState } from 'react';
|
||||
import { useMessages, useWebsiteEventsQuery } from '@/components/hooks';
|
||||
import { EventsTable } from './EventsTable';
|
||||
import { DataGrid } from '@/components/common/DataGrid';
|
||||
import { ReactNode } from 'react';
|
||||
import { FilterButtons } from '@/components/common/FilterButtons';
|
||||
|
||||
export function EventsDataTable({
|
||||
websiteId,
|
||||
|
|
@ -10,10 +12,37 @@ export function EventsDataTable({
|
|||
teamId?: string;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const queryResult = useWebsiteEventsQuery(websiteId);
|
||||
const [view, setView] = useState('all');
|
||||
|
||||
const buttons = [
|
||||
{
|
||||
id: 'all',
|
||||
label: formatMessage(labels.all),
|
||||
},
|
||||
{
|
||||
id: 'page',
|
||||
label: formatMessage(labels.page),
|
||||
},
|
||||
{
|
||||
id: 'event',
|
||||
label: formatMessage(labels.event),
|
||||
},
|
||||
];
|
||||
|
||||
const renderActions = () => {
|
||||
return <FilterButtons items={buttons} value={view} onChange={setView} />;
|
||||
};
|
||||
|
||||
return (
|
||||
<DataGrid queryResult={queryResult} allowSearch={true} autoFocus={false}>
|
||||
<DataGrid
|
||||
queryResult={queryResult}
|
||||
allowSearch={true}
|
||||
autoFocus={false}
|
||||
allowPaging={true}
|
||||
renderActions={renderActions}
|
||||
>
|
||||
{({ data }) => <EventsTable data={data} />}
|
||||
</DataGrid>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue