Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 7x 3x 3x 5x 2x 2x 4x 1x 1x | import { useQuery } from "@tanstack/react-query";
import { proApi } from "../../lib/api";
import { queryKeys } from "../../lib/query-keys";
export function useMyBlogs(
proId: string | null,
filters?: { status?: string },
) {
return useQuery({
queryKey: queryKeys.blogs.list(proId ?? "", filters),
queryFn: async () => {
const response = await proApi.listMyBlogs(
proId as string,
filters,
);
return response.data || [];
},
enabled: !!proId,
});
}
export function useBlogTags(proId: string | null) {
return useQuery({
queryKey: queryKeys.blogs.tags(proId ?? ""),
queryFn: async () => {
const response = await proApi.listBlogTags(proId as string);
return response.data || [];
},
enabled: !!proId,
staleTime: 1000 * 60 * 60, // Tags rarely change
});
}
export function useMyBlog(proId: string | null, blogId: string | null) {
return useQuery({
queryKey: queryKeys.blogs.detail(proId ?? "", blogId ?? ""),
queryFn: async () => {
const response = await proApi.getMyBlog(
proId as string,
blogId as string,
);
return response.data;
},
enabled: !!proId && !!blogId,
});
}
|