Add link and pixel selectors to top nav

This commit is contained in:
Mike Cao committed 2026-02-12 17:01:37 -08:00
1 parent dd2d6bca45
commit a1f3ad89f6
6 files changed
+255 -17

No files matched your search

+10 -3
View File
@@ -3,14 +3,21 @@ import { useApi } from '../useApi';
import { useModified } from '../useModified';
import { usePagedQuery } from '../usePagedQuery';
export function useLinksQuery({ teamId }: { teamId?: string }, options?: ReactQueryOptions) {
export function useLinksQuery(
{ teamId }: { teamId?: string },
params?: Record<string, any>,
options?: ReactQueryOptions,
) {
const { modified } = useModified('links');
const { get } = useApi();
return usePagedQuery({
queryKey: ['links', { teamId, modified }],
queryKey: ['links', { teamId, modified, ...params }],
queryFn: pageParams => {
return get(teamId ? `/teams/${teamId}/links` : '/links', pageParams);
return get(teamId ? `/teams/${teamId}/links` : '/links', {
...pageParams,
...params,
});
},
...options,
});
+10 -3
View File
@@ -3,14 +3,21 @@ import { useApi } from '../useApi';
import { useModified } from '../useModified';
import { usePagedQuery } from '../usePagedQuery';
export function usePixelsQuery({ teamId }: { teamId?: string }, options?: ReactQueryOptions) {
export function usePixelsQuery(
{ teamId }: { teamId?: string },
params?: Record<string, any>,
options?: ReactQueryOptions,
) {
const { modified } = useModified('pixels');
const { get } = useApi();
return usePagedQuery({
queryKey: ['pixels', { teamId, modified }],
queryKey: ['pixels', { teamId, modified, ...params }],
queryFn: pageParams => {
return get(teamId ? `/teams/${teamId}/pixels` : '/pixels', pageParams);
return get(teamId ? `/teams/${teamId}/pixels` : '/pixels', {
...pageParams,
...params,
});
},
...options,
});
+4
View File
@@ -8,6 +8,8 @@ export function useNavigation() {
const searchParams = useSearchParams();
const [, teamId] = pathname.match(/\/teams\/([a-f0-9-]+)/) || [];
const [, websiteId] = pathname.match(/\/websites\/([a-f0-9-]+)/) || [];
const [, linkId] = pathname.match(/\/links\/([a-f0-9-]+)/) || [];
const [, pixelId] = pathname.match(/\/pixels\/([a-f0-9-]+)/) || [];
const [queryParams, setQueryParams] = useState(Object.fromEntries(searchParams));
const updateParams = (params?: Record<string, string | number>) => {
@@ -36,6 +38,8 @@ export function useNavigation() {
query: queryParams,
teamId,
websiteId,
linkId,
pixelId,
updateParams,
replaceParams,
renderUrl,