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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 8x 8x 8x 8x 8x 4x 4x 3x 1x 1x 4x 2x 2x 4x 2x 2x 6x 6x 6x 3x 3x | import { useQuery } from "@tanstack/react-query";
import { adminApi } from "../../lib/api";
import { queryKeys } from "../../lib/query-keys";
export function useAdminBlogs(filters?: {
status?: string;
ideaSource?: string;
search?: string;
}) {
const filterParams: Record<string, string> = {};
if (filters?.status) filterParams.status = filters.status;
if (filters?.ideaSource) filterParams.ideaSource = filters.ideaSource;
if (filters?.search) filterParams.search = filters.search;
return useQuery({
queryKey: queryKeys.admin.blogs.list(filterParams),
queryFn: async () => {
const response = await adminApi.listBlogs(filterParams);
return response.data || [];
},
});
}
export function useAdminBlog(blogId: string | null) {
return useQuery({
queryKey: queryKeys.admin.blogs.detail(blogId ?? ""),
queryFn: async () => {
const response = await adminApi.getBlog(blogId as string);
return response.data;
},
enabled: !!blogId,
});
}
export function useAdminBlogCategories() {
return useQuery({
queryKey: queryKeys.admin.blogs.categories(),
queryFn: async () => {
const response = await adminApi.listBlogCategories(true);
return response.data || [];
},
staleTime: 1000 * 60 * 5,
});
}
export function useAdminBlogTags() {
return useQuery({
queryKey: queryKeys.admin.blogs.tags(),
queryFn: async () => {
const response = await adminApi.listBlogTags();
return response.data || [];
},
staleTime: 1000 * 60 * 5,
});
}
export function useAdminBlogSuggestions(filters?: { status?: string }) {
const filterParams: Record<string, string> = {};
if (filters?.status) filterParams.status = filters.status;
return useQuery({
queryKey: queryKeys.admin.blogs.suggestions(filterParams),
queryFn: async () => {
const response = await adminApi.listBlogSuggestions(
filters?.status,
);
return response.data || [];
},
});
}
|