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 | 327x 74x 11x 4x 1x 1x 4x 1x | import { useQuery } from "@tanstack/react-query";
import { projectsApi } from "../../lib/api/pro/projects";
import { proApi } from "../../lib/api";
import { queryKeys } from "../../lib/query-keys";
export function useProjects(proId: string | null) {
return useQuery({
queryKey: queryKeys.projects.list(proId ?? ""),
queryFn: async () => {
const response = await proApi.listProjects(proId as string);
return response.data || [];
},
enabled: !!proId,
});
}
/**
* Like useProjects but fetches with ?includePhotoCount=1.
* Uses a distinct query key so it doesn't poison the plain list cache.
* F-008 client.
*/
export function useProjectsWithPhotoCount(proId: string | null) {
return useQuery({
queryKey: [...queryKeys.projects.list(proId ?? ""), "withPhotoCount"] as const,
queryFn: async () => {
const response = await projectsApi.list(proId as string, undefined, {
includePhotoCount: true,
});
return response.data || [];
},
enabled: !!proId,
});
}
export function useProject(proId: string | null, projectId: string) {
return useQuery({
queryKey: queryKeys.projects.detail(proId ?? "", projectId),
queryFn: async () => {
const response = await proApi.getProject(
proId as string,
projectId,
);
return response.data;
},
enabled: !!proId && !!projectId,
});
}
/** @deprecated project_photos table removed — always returns empty array */
export function useProjectPhotos(
_proId: string | null,
_projectId: string | null,
) {
return useQuery({
queryKey: ["photos", "list", _proId ?? "", _projectId ?? ""],
queryFn: async () => [] as unknown[],
enabled: false,
});
}
|