mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 17:45:38 +01:00
Prevent admin from resetting their own role.
This commit is contained in:
parent
2e871af05b
commit
f25cd93012
10 changed files with 66 additions and 31 deletions
24
src/app/(main)/settings/users/[userId]/UserProvider.tsx
Normal file
24
src/app/(main)/settings/users/[userId]/UserProvider.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { createContext, ReactNode, useEffect } from 'react';
|
||||
import { useModified, useUser } from 'components/hooks';
|
||||
import { Loading } from 'react-basics';
|
||||
|
||||
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 } = useUser(userId);
|
||||
|
||||
useEffect(() => {
|
||||
if (modified) {
|
||||
refetch();
|
||||
}
|
||||
}, [modified]);
|
||||
|
||||
if (isFetching && isLoading) {
|
||||
return <Loading position="page" />;
|
||||
}
|
||||
|
||||
return <UserContext.Provider value={user}>{children}</UserContext.Provider>;
|
||||
}
|
||||
|
||||
export default UserProvider;
|
||||
Loading…
Add table
Add a link
Reference in a new issue