mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Redesigned share page.
This commit is contained in:
parent
9d3f5ad0fd
commit
78d467b478
9 changed files with 130 additions and 88 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
NavMenuItem,
|
||||
type NavMenuProps,
|
||||
Row,
|
||||
Text,
|
||||
} from '@umami/react-zen';
|
||||
import Link from 'next/link';
|
||||
|
||||
|
|
@ -42,9 +43,11 @@ export function SideMenu({
|
|||
|
||||
return (
|
||||
<Link key={id} href={path}>
|
||||
<NavMenuItem isSelected={isSelected}>
|
||||
<IconLabel icon={icon}>{label}</IconLabel>
|
||||
</NavMenuItem>
|
||||
<Row padding hoverBackgroundColor="3">
|
||||
<IconLabel icon={icon}>
|
||||
<Text weight={isSelected ? 'bold' : undefined}>{label}</Text>
|
||||
</IconLabel>
|
||||
</Row>
|
||||
</Link>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
6
src/components/hooks/context/useShare.ts
Normal file
6
src/components/hooks/context/useShare.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { useContext } from 'react';
|
||||
import { ShareContext } from '@/app/share/ShareProvider';
|
||||
|
||||
export function useShare() {
|
||||
return useContext(ShareContext);
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
// Context hooks
|
||||
export * from './context/useLink';
|
||||
export * from './context/usePixel';
|
||||
export * from './context/useShare';
|
||||
export * from './context/useTeam';
|
||||
export * from './context/useUser';
|
||||
export * from './context/useWebsite';
|
||||
|
|
|
|||
|
|
@ -1,25 +1,21 @@
|
|||
import { setShareToken, useApp } from '@/store/app';
|
||||
import { setShare, useApp } from '@/store/app';
|
||||
import { useApi } from '../useApi';
|
||||
|
||||
const selector = (state: { shareToken: string }) => state.shareToken;
|
||||
const selector = state => state.share;
|
||||
|
||||
export function useShareTokenQuery(slug: string): {
|
||||
shareToken: any;
|
||||
isLoading?: boolean;
|
||||
error?: Error;
|
||||
} {
|
||||
const shareToken = useApp(selector);
|
||||
export function useShareTokenQuery(slug: string) {
|
||||
const share = useApp(selector);
|
||||
const { get, useQuery } = useApi();
|
||||
const { isLoading, error } = useQuery({
|
||||
const query = useQuery({
|
||||
queryKey: ['share', slug],
|
||||
queryFn: async () => {
|
||||
const data = await get(`/share/${slug}`);
|
||||
|
||||
setShareToken(data);
|
||||
setShare(data);
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
|
||||
return { shareToken, isLoading, error };
|
||||
return { share, ...query };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue