mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Added segment filtering to filter form.
This commit is contained in:
parent
2e69e57445
commit
2ad624ccc8
15 changed files with 301 additions and 193 deletions
|
|
@ -26,6 +26,7 @@ export * from './queries/useTeamMembersQuery';
|
|||
export * from './queries/useUserQuery';
|
||||
export * from './queries/useUsersQuery';
|
||||
export * from './queries/useWebsiteQuery';
|
||||
export * from './queries/useWebsiteSegementsQuery';
|
||||
export * from './queries/useWebsitesQuery';
|
||||
export * from './queries/useWebsiteEventsQuery';
|
||||
export * from './queries/useWebsiteEventsSeriesQuery';
|
||||
|
|
|
|||
21
src/components/hooks/queries/useWebsiteSegementsQuery.ts
Normal file
21
src/components/hooks/queries/useWebsiteSegementsQuery.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '@/components/hooks';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useWebsiteSegmentsQuery(
|
||||
websiteId: string,
|
||||
params?: Record<string, string>,
|
||||
options?: ReactQueryOptions<any>,
|
||||
) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`website:${websiteId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['website:segments', { websiteId, modified, ...params }],
|
||||
queryFn: () => get(`/websites/${websiteId}/segments`, { ...params }),
|
||||
enabled: !!websiteId,
|
||||
placeholderData: keepPreviousData,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ export function useFields() {
|
|||
const fields = [
|
||||
{ name: 'path', type: 'string', label: formatMessage(labels.path) },
|
||||
// { name: 'cohort', type: 'string', label: formatMessage(labels.cohort) },
|
||||
// { name: 'segment', type: 'string', label: formatMessage(labels.segment) },
|
||||
{ name: 'title', type: 'string', label: formatMessage(labels.pageTitle) },
|
||||
{ name: 'referrer', type: 'string', label: formatMessage(labels.referrer) },
|
||||
//{ name: 'query', type: 'string', label: formatMessage(labels.query) },
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ export function useNavigation() {
|
|||
const [queryParams, setQueryParams] = useState(Object.fromEntries(searchParams));
|
||||
|
||||
const updateParams = (params?: Record<string, string | number>) => {
|
||||
return !params ? pathname : buildUrl(pathname, { ...queryParams, ...params });
|
||||
return buildUrl(pathname, { ...queryParams, ...params });
|
||||
};
|
||||
|
||||
const replaceParams = (params?: Record<string, string | number>) => {
|
||||
return buildUrl(pathname, params);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -33,6 +37,7 @@ export function useNavigation() {
|
|||
teamId,
|
||||
websiteId,
|
||||
updateParams,
|
||||
replaceParams,
|
||||
renderUrl,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue