This commit is contained in:
2024-07-29 00:40:35 +02:00
parent 7723dd0722
commit 0b661c7ccc
33 changed files with 620 additions and 372 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
import { queryOptions } from '@tanstack/react-query';
import Api from '../api/Api';
import { useApi } from '../api/Api';
export const postsQueryOptions = (page?: number) =>
export const postsQueryOptions = (Api: ReturnType<typeof useApi>, page?: number) =>
queryOptions({
queryKey: ['posts', { page: page ?? 0, hasAuth: Api.hasAuth() }],
queryFn: () => Api.posts(page),
queryKey: ['posts', { page: page ?? 0, hasAuth: Api.hasAuth }],
queryFn: async () => await Api.posts(page),
});
+10 -9
View File
@@ -1,19 +1,20 @@
import { queryOptions } from '@tanstack/react-query';
import Api from '../api/Api';
import { useApi } from '../api/Api';
export const profileSelfQueryOptions = queryOptions({
queryKey: ['profile'],
queryFn: () => Api.user(),
});
export const profileSelfQueryOptions = (Api: ReturnType<typeof useApi>) =>
queryOptions({
queryKey: ['profile'],
queryFn: async () => await Api.user(),
});
export const profileQueryOptions = (id?: number) =>
export const profileQueryOptions = (Api: ReturnType<typeof useApi>, id?: number) =>
queryOptions({
queryKey: ['profile', { id }],
queryFn: () => Api.user(id),
queryFn: async () => await Api.user(id),
});
export const profilePostsQueryOptions = (id: number) =>
export const profilePostsQueryOptions = (Api: ReturnType<typeof useApi>, id: number) =>
queryOptions({
queryKey: ['profilePosts', { id }],
queryFn: () => Api.userPosts(id),
queryFn: async () => await Api.userPosts(id),
});