import { API_ENDPOINTS, fileService } from "@/lib/api";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";

/** Fetches (and caches) metadata for a single stored file. */
export const useFileInfo = (fileId: string, options?: { enabled?: boolean }) => {
  const queryKey = useMemo(() => [API_ENDPOINTS.FILES.INFO(fileId)], [fileId]);
  return useQuery({
    queryKey,
    queryFn: () => fileService.getFileInfo(fileId),
    enabled: (options?.enabled ?? true) && Boolean(fileId),
    staleTime: 5 * 60 * 1000,
  });
};
