mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Settings refactor.
This commit is contained in:
parent
1b81074752
commit
c98f324c22
56 changed files with 706 additions and 348 deletions
|
|
@ -1,10 +1,17 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '@/components/hooks';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useTeamQuery(teamId: string) {
|
||||
export function useTeamQuery(teamId: string, options?: ReactQueryOptions<any>) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`teams:${teamId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['teams', teamId],
|
||||
queryKey: ['teams', { teamId, modified }],
|
||||
queryFn: () => get(`/teams/${teamId}`),
|
||||
enabled: !!teamId,
|
||||
placeholderData: keepPreviousData,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '@/components/hooks';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useUserQuery(userId: string, options?: Record<string, any>) {
|
||||
export function useUserQuery(userId: string, options?: ReactQueryOptions<any>) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`user:${userId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['users', userId],
|
||||
queryKey: ['users', { userId, modified }],
|
||||
queryFn: () => get(`/users/${userId}`),
|
||||
enabled: !!userId,
|
||||
placeholderData: keepPreviousData,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
import { useApi } from '../useApi';
|
||||
import { useModified } from '@/components/hooks';
|
||||
import { keepPreviousData } from '@tanstack/react-query';
|
||||
import { ReactQueryOptions } from '@/lib/types';
|
||||
|
||||
export function useWebsiteQuery(websiteId: string, options?: Record<string, any>) {
|
||||
export function useWebsiteQuery(websiteId: string, options?: ReactQueryOptions<any>) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { modified } = useModified(`website:${websiteId}`);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['website', { websiteId }],
|
||||
queryKey: ['website', { websiteId, modified }],
|
||||
queryFn: () => get(`/websites/${websiteId}`),
|
||||
enabled: !!websiteId,
|
||||
placeholderData: keepPreviousData,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue