mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Pixel/link metrics pages.
This commit is contained in:
parent
789b8b36d8
commit
8e766e2db7
42 changed files with 530 additions and 49 deletions
6
src/components/hooks/context/useLink.ts
Normal file
6
src/components/hooks/context/useLink.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { LinkContext } from '@/app/(main)/links/LinkProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function useLink() {
|
||||
return useContext(LinkContext);
|
||||
}
|
||||
6
src/components/hooks/context/usePixel.ts
Normal file
6
src/components/hooks/context/usePixel.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { PixelContext } from '@/app/(main)/pixels/PixelProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function usePixel() {
|
||||
return useContext(PixelContext);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { TeamContext } from '@/app/(main)/teams/[teamId]/TeamProvider';
|
||||
import { TeamContext } from '@/app/(main)/teams/TeamProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function useTeam() {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { WebsiteContext } from '@/app/(main)/websites/[websiteId]/WebsiteProvider';
|
||||
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export function useWebsite() {
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
'use client';
|
||||
|
||||
// Context hooks
|
||||
export * from './context/useLink';
|
||||
export * from './context/usePixel';
|
||||
export * from './context/useTeam';
|
||||
export * from './context/useWebsite';
|
||||
|
||||
// Query hooks
|
||||
export * from './queries/useActiveUsersQuery';
|
||||
export * from './queries/useDeleteQuery';
|
||||
|
|
@ -70,7 +76,6 @@ export * from './useNavigation';
|
|||
export * from './usePagedQuery';
|
||||
export * from './usePageParameters';
|
||||
export * from './useRegionNames';
|
||||
export * from './useSlug';
|
||||
export * from './useSticky';
|
||||
export * from './useTeam';
|
||||
export * from './useTimezone';
|
||||
export * from './useWebsite';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { useApi, useModified } from '@/components/hooks';
|
||||
import { useApi } from '../useApi';
|
||||
import { useModified } from '../useModified';
|
||||
import { useToast } from '@umami/react-zen';
|
||||
|
||||
export function useUpdateQuery(path: string, params?: Record<string, any>) {
|
||||
const { post, useMutation } = useApi();
|
||||
|
|
@ -6,6 +8,7 @@ export function useUpdateQuery(path: string, params?: Record<string, any>) {
|
|||
mutationFn: (data: Record<string, any>) => post(path, { ...data, ...params }),
|
||||
});
|
||||
const { touch } = useModified();
|
||||
const { toast } = useToast();
|
||||
|
||||
return { mutate, isPending, error, touch };
|
||||
return { mutate, isPending, error, touch, toast };
|
||||
}
|
||||
|
|
|
|||
14
src/components/hooks/useSlug.ts
Normal file
14
src/components/hooks/useSlug.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { useConfig } from '@/components/hooks/useConfig';
|
||||
import { LINKS_URL, PIXELS_URL } from '@/lib/constants';
|
||||
|
||||
export function useSlug(type: 'link' | 'pixel') {
|
||||
const { linksUrl, pixelsUrl } = useConfig();
|
||||
|
||||
const hostUrl = type === 'link' ? linksUrl || LINKS_URL : pixelsUrl || PIXELS_URL;
|
||||
|
||||
const getSlugUrl = (slug: string) => {
|
||||
return `${hostUrl}/${slug}`;
|
||||
};
|
||||
|
||||
return { getSlugUrl, hostUrl };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue