import { queryOptions } from '@tanstack/react-query'; import { useApi } from '../api/Api'; export const profileSelfQueryOptions = (Api: ReturnType) => queryOptions({ queryKey: ['profile', { id: Api.authenticatedUser?.id }], queryFn: async () => ({ user: await Api.user(), posts: await Api.userPosts(Api.authenticatedUser?.id ?? 0), }), }); export const profileQueryOptions = (Api: ReturnType, id?: number) => queryOptions({ queryKey: ['profile', { id }], queryFn: async () => ({ user: await Api.user(id), posts: await Api.userPosts(id) }), });