Pixel/link metrics pages.

This commit is contained in:
Mike Cao 2025-08-21 01:33:20 -07:00
parent 789b8b36d8
commit 8e766e2db7
42 changed files with 530 additions and 49 deletions

View file

@ -0,0 +1,6 @@
import { LinkContext } from '@/app/(main)/links/LinkProvider';
import { useContext } from 'react';
export function useLink() {
return useContext(LinkContext);
}

View file

@ -0,0 +1,6 @@
import { PixelContext } from '@/app/(main)/pixels/PixelProvider';
import { useContext } from 'react';
export function usePixel() {
return useContext(PixelContext);
}

View file

@ -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() {

View file

@ -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() {

View file

@ -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';

View file

@ -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 };
}

View 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 };
}