mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Updated events/sessions pages. Added DateDistance component.
This commit is contained in:
parent
8b64029409
commit
5b300f1ff5
13 changed files with 44 additions and 35 deletions
|
|
@ -2,7 +2,7 @@ import { useApi } from '../useApi';
|
|||
import { useFilterParams } from '../useFilterParams';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useResultQuery<T>(
|
||||
export function useResultQuery<T = any>(
|
||||
type: string,
|
||||
params?: { [key: string]: any },
|
||||
options?: ReactQueryOptions<T>,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { usePagedQuery } from '../usePagedQuery';
|
||||
import { useModified } from '../useModified';
|
||||
|
||||
export function useTeamsQuery(userId: string) {
|
||||
const { get } = useApi();
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`teams`);
|
||||
|
||||
return usePagedQuery({
|
||||
return useQuery({
|
||||
queryKey: ['teams', { userId, modified }],
|
||||
queryFn: (params: any) => {
|
||||
return get(`/users/${userId}/teams`, params);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,11 @@ import { ReactQueryOptions } from '@/lib/types';
|
|||
|
||||
export function useWebsiteEventsQuery(websiteId: string, options?: ReactQueryOptions<any>) {
|
||||
const { get } = useApi();
|
||||
const params = useFilterParams(websiteId);
|
||||
const filterParams = useFilterParams(websiteId);
|
||||
|
||||
return usePagedQuery({
|
||||
queryKey: ['websites:events', { websiteId, ...params }],
|
||||
queryFn: pageParams =>
|
||||
get(`/websites/${websiteId}/events`, { ...params, ...pageParams, pageSize: 20 }),
|
||||
queryKey: ['websites:events', { websiteId, ...filterParams }],
|
||||
queryFn: () => get(`/websites/${websiteId}/events`, { ...filterParams, pageSize: 20 }),
|
||||
enabled: !!websiteId,
|
||||
...options,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,14 +22,19 @@ export function useFilterParams(websiteId: string) {
|
|||
event,
|
||||
tag,
|
||||
hostname,
|
||||
page,
|
||||
pageSize,
|
||||
search,
|
||||
},
|
||||
} = useNavigation();
|
||||
|
||||
return {
|
||||
// Date range
|
||||
startAt: +toUtc(startDate),
|
||||
endAt: +toUtc(endDate),
|
||||
unit,
|
||||
timezone,
|
||||
// Filters
|
||||
path,
|
||||
referrer,
|
||||
title,
|
||||
|
|
@ -44,5 +49,9 @@ export function useFilterParams(websiteId: string) {
|
|||
event,
|
||||
tag,
|
||||
hostname,
|
||||
// Paging
|
||||
page,
|
||||
pageSize,
|
||||
search,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export function usePagedQuery<T = any>({
|
|||
const { query: queryParams } = useNavigation();
|
||||
const [params, setParams] = useState<PageParams>({
|
||||
search: '',
|
||||
page: +queryParams?.page || 1,
|
||||
page: queryParams?.page || '1',
|
||||
});
|
||||
|
||||
const { useQuery } = useApi();
|
||||
|
|
@ -25,7 +25,7 @@ export function usePagedQuery<T = any>({
|
|||
return {
|
||||
result: data as PageResult<T>,
|
||||
query,
|
||||
filterParams: params,
|
||||
params,
|
||||
setParams,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue