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 | 2x 1x 1x 2x 1x 2x 1x 1x 1x | import { useQuery } from "@tanstack/react-query";
import { adminApi } from "../../lib/api";
import { queryKeys } from "../../lib/query-keys";
import { STALE_5MIN } from "../../lib/stale-times";
import type { BlogMediaPage } from "../../lib/api/blog-images";
export function useAdminBlogImages(blogId: string | null) {
return useQuery({
queryKey: queryKeys.blogImages.adminList(blogId ?? ""),
queryFn: async () => {
const response = await adminApi.getAdminBlogImages(blogId as string);
return response.data ?? [];
},
enabled: !!blogId,
staleTime: STALE_5MIN,
});
}
export function useAllProsMediaSearch(
blogId: string | null,
search: string,
proId: string | undefined,
page = 1,
) {
return useQuery<BlogMediaPage>({
queryKey: queryKeys.blogImages.allProsMedia(blogId ?? "", search, proId, page),
queryFn: async () => {
return adminApi.searchAllProsMedia(blogId as string, {
search,
proId,
page,
perPage: 20,
});
},
enabled: !!blogId,
staleTime: STALE_5MIN,
});
}
export function useAdminPexelsSearch(query: string, page = 1) {
return useQuery({
queryKey: queryKeys.blogImages.adminPexelsSearch(query, page),
queryFn: async () => {
Iif (!query || query.trim().length === 0) {
return { photos: [], page: 1, per_page: 20, total_results: 0 };
}
const response = await adminApi.searchAdminPexels(query, page);
// The admin pexels search returns the same PexelsSearchResult shape
return response.data as {
photos: unknown[];
page: number;
per_page: number;
total_results: number;
next_page?: string;
prev_page?: string;
};
},
enabled: query.trim().length > 0,
staleTime: STALE_5MIN,
});
}
|