mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Updated query hooks for teams and websites.
This commit is contained in:
parent
9448aa3ab5
commit
2fa50892d8
61 changed files with 508 additions and 539 deletions
|
|
@ -1,11 +1,13 @@
|
|||
import useStore, { setUser } from 'store/app';
|
||||
import useApi from './useApi';
|
||||
|
||||
const selector = (state: { user: any }) => state.user;
|
||||
|
||||
export function useUser() {
|
||||
const user = useStore(selector);
|
||||
|
||||
return { user, setUser };
|
||||
export function useUser(userId: string, options?: { [key: string]: any }) {
|
||||
const { get, useQuery } = useApi();
|
||||
return useQuery({
|
||||
queryKey: ['users', userId],
|
||||
queryFn: () => get(`/users/${userId}`),
|
||||
enabled: !!userId,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export default useUser;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue