mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
Redesigned share page.
This commit is contained in:
parent
9d3f5ad0fd
commit
78d467b478
9 changed files with 130 additions and 88 deletions
29
src/app/share/ShareProvider.tsx
Normal file
29
src/app/share/ShareProvider.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
'use client';
|
||||
import { Loading } from '@umami/react-zen';
|
||||
import { createContext, type ReactNode } from 'react';
|
||||
import { useShareTokenQuery } from '@/components/hooks';
|
||||
import type { WhiteLabel } from '@/lib/types';
|
||||
|
||||
export interface ShareData {
|
||||
shareId: string;
|
||||
websiteId: string;
|
||||
parameters: any;
|
||||
token: string;
|
||||
whiteLabel?: WhiteLabel;
|
||||
}
|
||||
|
||||
export const ShareContext = createContext<ShareData>(null);
|
||||
|
||||
export function ShareProvider({ shareId, children }: { shareId: string; children: ReactNode }) {
|
||||
const { share, isLoading, isFetching } = useShareTokenQuery(shareId);
|
||||
|
||||
if (isFetching && isLoading) {
|
||||
return <Loading placement="absolute" />;
|
||||
}
|
||||
|
||||
if (!share) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <ShareContext.Provider value={share}>{children}</ShareContext.Provider>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue