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

@ -1,5 +1,5 @@
import { ReactNode } from 'react';
import { Heading, Icon, Row, RowProps, Text } from '@umami/react-zen';
import { Heading, Icon, Row, RowProps, Text, Column } from '@umami/react-zen';
export function PageHeader({
title,
@ -26,11 +26,13 @@ export function PageHeader({
width="100%"
{...props}
>
<Row alignItems="center" gap="3">
{icon && <Icon size="md">{icon}</Icon>}
{title && <Heading size="4">{title}</Heading>}
<Column>
<Row alignItems="center" gap="3">
{icon && <Icon size="md">{icon}</Icon>}
{title && <Heading size="4">{title}</Heading>}
</Row>
{description && <Text color="muted">{description}</Text>}
</Row>
</Column>
<Row justifyContent="flex-end">{children}</Row>
</Row>
);

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

View file

@ -358,7 +358,7 @@ export const labels = defineMessages({
export const messages = defineMessages({
error: { id: 'message.error', defaultMessage: 'Something went wrong.' },
saved: { id: 'message.saved', defaultMessage: 'Saved.' },
saved: { id: 'message.saved', defaultMessage: 'Saved successfully.' },
noUsers: { id: 'message.no-users', defaultMessage: 'There are no users.' },
userDeleted: { id: 'message.user-deleted', defaultMessage: 'User deleted.' },
noDataAvailable: { id: 'message.no-data-available', defaultMessage: 'No data available.' },

View file

@ -1,4 +1,4 @@
import { WebsiteContext } from '@/app/(main)/websites/[websiteId]/WebsiteProvider';
import { WebsiteContext } from '@/app/(main)/websites/WebsiteProvider';
import { FilterButtons } from '@/components/input/FilterButtons';
import { FilterLink } from '@/components/common/FilterLink';
import { useMessages, useNavigation } from '@/components/hooks';