mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 18:15:35 +01:00
Pixel/link metrics pages.
This commit is contained in:
parent
789b8b36d8
commit
8e766e2db7
42 changed files with 530 additions and 49 deletions
27
src/app/(main)/websites/WebsiteProvider.tsx
Normal file
27
src/app/(main)/websites/WebsiteProvider.tsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
'use client';
|
||||
import { createContext, ReactNode } from 'react';
|
||||
import { useWebsiteQuery } from '@/components/hooks';
|
||||
import { Loading } from '@umami/react-zen';
|
||||
import { Website } from '@/generated/prisma/client';
|
||||
|
||||
export const WebsiteContext = createContext<Website>(null);
|
||||
|
||||
export function WebsiteProvider({
|
||||
websiteId,
|
||||
children,
|
||||
}: {
|
||||
websiteId: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const { data: website, isFetching, isLoading } = useWebsiteQuery(websiteId);
|
||||
|
||||
if (isFetching && isLoading) {
|
||||
return <Loading position="page" />;
|
||||
}
|
||||
|
||||
if (!website) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <WebsiteContext.Provider value={website}>{children}</WebsiteContext.Provider>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue