mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
New admin section.
This commit is contained in:
parent
cdf391d5c2
commit
b78ff3b477
28 changed files with 161 additions and 100 deletions
22
src/app/(main)/admin/users/[userId]/UserProvider.tsx
Normal file
22
src/app/(main)/admin/users/[userId]/UserProvider.tsx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { createContext, ReactNode, useEffect } from 'react';
|
||||
import { Loading } from '@umami/react-zen';
|
||||
import { useModified, useUserQuery } from '@/components/hooks';
|
||||
|
||||
export const UserContext = createContext(null);
|
||||
|
||||
export function UserProvider({ userId, children }: { userId: string; children: ReactNode }) {
|
||||
const { modified } = useModified(`user:${userId}`);
|
||||
const { data: user, isFetching, isLoading, refetch } = useUserQuery(userId);
|
||||
|
||||
useEffect(() => {
|
||||
if (modified) {
|
||||
refetch();
|
||||
}
|
||||
}, [modified]);
|
||||
|
||||
if (isFetching && isLoading) {
|
||||
return <Loading position="page" />;
|
||||
}
|
||||
|
||||
return <UserContext.Provider value={{ ...user, modified }}>{children}</UserContext.Provider>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue