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

export const useTendersQuery = (params?: Record<string, any>) => {
  const queryKey = useMemo(
    () => [API_ENDPOINTS.TENDERS.READ_ALL, "read-tenders", params],
    [params],
  );

  return useQuery({
    queryKey,
    queryFn: () => tendersService.tendersList({ ...params }),
  });
};

export const useTenderDetailQuery = (id: string) => {
  const queryKey = useMemo(() => [API_ENDPOINTS.TENDERS.DETAILS(id)], [id]);
  return useQuery({
    queryKey,
    queryFn: () => tendersService.tenderDetails(id),
  });
};
