mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
New schema for pixels and links.
This commit is contained in:
parent
c60e8b3d23
commit
88639dfe83
67 changed files with 993 additions and 208 deletions
|
|
@ -4,7 +4,11 @@ export * from './queries/useEventDataQuery';
|
|||
export * from './queries/useEventDataEventsQuery';
|
||||
export * from './queries/useEventDataPropertiesQuery';
|
||||
export * from './queries/useEventDataValuesQuery';
|
||||
export * from './queries/useLinkQuery';
|
||||
export * from './queries/useLinksQuery';
|
||||
export * from './queries/useLoginQuery';
|
||||
export * from './queries/usePixelQuery';
|
||||
export * from './queries/usePixelsQuery';
|
||||
export * from './queries/useRealtimeQuery';
|
||||
export * from './queries/useResultQuery';
|
||||
export * from './queries/useReportQuery';
|
||||
|
|
@ -49,8 +53,10 @@ export * from './useLanguageNames';
|
|||
export * from './useLocale';
|
||||
export * from './useMessages';
|
||||
export * from './useModified';
|
||||
export * from './useNavigation';
|
||||
export * from './usePagedQuery';
|
||||
export * from './useRegionNames';
|
||||
export * from './useSticky';
|
||||
export * from './useNavigation';
|
||||
export * from './useTeam';
|
||||
export * from './useTimezone';
|
||||
export * from './useWebsite';
|
||||
|
|
|
|||
15
src/components/hooks/queries/useLinkQuery.ts
Normal file
15
src/components/hooks/queries/useLinkQuery.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '../useModified';
|
||||
|
||||
export function useLinkQuery(linkId: string) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`link:${linkId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['link', { linkId, modified }],
|
||||
queryFn: () => {
|
||||
return get(`/link/${linkId}`);
|
||||
},
|
||||
enabled: !!linkId,
|
||||
});
|
||||
}
|
||||
15
src/components/hooks/queries/useLinksQuery.ts
Normal file
15
src/components/hooks/queries/useLinksQuery.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { usePagedQuery } from '../usePagedQuery';
|
||||
import { useModified } from '../useModified';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useLinksQuery({ teamId }: { teamId?: string }, options?: ReactQueryOptions<any>) {
|
||||
const { modified } = useModified('links');
|
||||
const { get } = useApi();
|
||||
|
||||
return usePagedQuery({
|
||||
queryKey: ['links', { teamId, modified }],
|
||||
queryFn: async () => get(teamId ? `/teams/${teamId}/links` : '/links'),
|
||||
...options,
|
||||
});
|
||||
}
|
||||
15
src/components/hooks/queries/usePixelQuery.ts
Normal file
15
src/components/hooks/queries/usePixelQuery.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '../useModified';
|
||||
|
||||
export function usePixelQuery(pixelId: string) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`pixel:${pixelId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['pixel', { pixelId, modified }],
|
||||
queryFn: () => {
|
||||
return get(`/pixel/${pixelId}`);
|
||||
},
|
||||
enabled: !!pixelId,
|
||||
});
|
||||
}
|
||||
19
src/components/hooks/queries/usePixelsQuery.ts
Normal file
19
src/components/hooks/queries/usePixelsQuery.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { usePagedQuery } from '../usePagedQuery';
|
||||
import { useModified } from '../useModified';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function usePixelsQuery(
|
||||
{ websiteId, type }: { websiteId: string; type?: string },
|
||||
options?: ReactQueryOptions<any>,
|
||||
) {
|
||||
const { modified } = useModified(`pixels:${type}`);
|
||||
const { get } = useApi();
|
||||
|
||||
return usePagedQuery({
|
||||
queryKey: ['pixels', { websiteId, type, modified }],
|
||||
queryFn: async () => get('/pixels', { websiteId, type }),
|
||||
enabled: !!websiteId && !!type,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
11
src/components/hooks/queries/useUpdateQuery.ts
Normal file
11
src/components/hooks/queries/useUpdateQuery.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { useApi, useModified } from '@/components/hooks';
|
||||
|
||||
export function useUpdateQuery(path: string, params?: Record<string, any>) {
|
||||
const { post, useMutation } = useApi();
|
||||
const { mutate, isPending, error } = useMutation({
|
||||
mutationFn: (data: Record<string, any>) => post(path, { ...data, ...params }),
|
||||
});
|
||||
const { touch } = useModified();
|
||||
|
||||
return { mutate, isPending, error, touch };
|
||||
}
|
||||
6
src/components/hooks/useTeam.ts
Normal file
6
src/components/hooks/useTeam.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { TeamContext } from '@/app/(main)/settings/teams/[teamId]/TeamProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function useTeam() {
|
||||
return useContext(TeamContext);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue