diff --git a/src/app/(main)/websites/[websiteId]/events/EventsDataTable.tsx b/src/app/(main)/websites/[websiteId]/events/EventsDataTable.tsx index 22b0f679..d93c7d8c 100644 --- a/src/app/(main)/websites/[websiteId]/events/EventsDataTable.tsx +++ b/src/app/(main)/websites/[websiteId]/events/EventsDataTable.tsx @@ -14,7 +14,7 @@ export function EventsDataTable({ }) { const { formatMessage, labels } = useMessages(); const [view, setView] = useState('all'); - const query = useWebsiteEventsQuery(websiteId); + const query = useWebsiteEventsQuery(websiteId, { view }); const buttons = [ { diff --git a/src/components/common/DataGrid.tsx b/src/components/common/DataGrid.tsx index 1533e25f..e112a410 100644 --- a/src/components/common/DataGrid.tsx +++ b/src/components/common/DataGrid.tsx @@ -16,6 +16,7 @@ export interface DataGridProps { allowPaging?: boolean; autoFocus?: boolean; renderActions?: () => ReactNode; + renderEmpty?: () => ReactNode; children: ReactNode | ((data: any) => ReactNode); } @@ -26,12 +27,13 @@ export function DataGrid({ allowPaging = true, autoFocus, renderActions, + renderEmpty = () => , children, }: DataGridProps) { const { formatMessage, labels } = useMessages(); const { data, error, isLoading, isFetching } = query; const { router, updateParams, query: queryParams } = useNavigation(); - const [search, setSearch] = useState(queryParams?.saerch || data?.search || ''); + const [search, setSearch] = useState(queryParams?.search || data?.search || ''); const handleSearch = (value: string) => { if (value !== search) { @@ -47,13 +49,9 @@ export function DataGrid({ [search], ); - if (data?.data?.length === 0) { - return ; - } - return ( - {allowSearch && (data || search) && ( + {allowSearch && ( )} - + {data && ( <> {typeof children === 'function' ? children(data) : children} diff --git a/src/components/hooks/queries/useWebsiteEventsQuery.ts b/src/components/hooks/queries/useWebsiteEventsQuery.ts index 3406285a..6a21f6df 100644 --- a/src/components/hooks/queries/useWebsiteEventsQuery.ts +++ b/src/components/hooks/queries/useWebsiteEventsQuery.ts @@ -4,6 +4,11 @@ import { useDateParameters } from '../useDateParameters'; import { usePagedQuery } from '../usePagedQuery'; import { ReactQueryOptions } from '@/lib/types'; +const EVENT_TYPES = { + views: 1, + events: 2, +}; + export function useWebsiteEventsQuery( websiteId: string, params?: Record, @@ -20,7 +25,7 @@ export function useWebsiteEventsQuery( ...date, ...filters, ...pageParams, - ...params, + eventType: EVENT_TYPES[params.view], }), enabled: !!websiteId, ...options, diff --git a/src/components/input/TeamsButton.tsx b/src/components/input/TeamsButton.tsx index b5288968..d9fd5e08 100644 --- a/src/components/input/TeamsButton.tsx +++ b/src/components/input/TeamsButton.tsx @@ -37,18 +37,18 @@ export function TeamsButton({ showText = true }: { showText?: boolean }) { return ( - : } - > - + + : } + > {showText && ( )} - - + + @@ -60,20 +60,24 @@ export function TeamsButton({ showText = true }: { showText?: boolean }) { > - - - - {user.username} + + + + + {user.username} + {data?.data?.map(({ id, name }) => ( - - - - {name} + + + + + {name} + ))} diff --git a/src/components/metrics/EventsTable.tsx b/src/components/metrics/EventsTable.tsx index 2ee4dace..f0f5d495 100644 --- a/src/components/metrics/EventsTable.tsx +++ b/src/components/metrics/EventsTable.tsx @@ -8,10 +8,6 @@ export interface EventsTableProps extends MetricsTableProps { export function EventsTable({ onLabelClick, ...props }: EventsTableProps) { const { formatMessage, labels } = useMessages(); - const handleDataLoad = (data: any) => { - props.onDataLoad?.(data); - }; - const renderLabel = ({ x: label }) => { if (onLabelClick) { return ( @@ -30,7 +26,6 @@ export function EventsTable({ onLabelClick, ...props }: EventsTableProps) { title={formatMessage(labels.events)} type="event" metric={formatMessage(labels.actions)} - onDataLoad={handleDataLoad} renderLabel={renderLabel} allowDownload={false} /> diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 0dc964e9..b5350872 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -71,6 +71,7 @@ export const FILTER_COLUMNS = { language: 'language', event: 'event_name', tag: 'tag', + eventType: 'event_type', }; export const COLLECTION_TYPE = { diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 2bcbb2bf..41931b7b 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -37,6 +37,7 @@ export const filterParams = { event: z.string().optional(), segment: z.string().optional(), cohort: z.string().optional(), + eventType: z.coerce.number().int().positive().optional(), }; export const searchParams = {