import { useQuery } from "@tanstack/react-query";
import {
  fetchListBulletResources,
  LIST_BULLET_RESOURCES_QUERY_KEY,
} from "@/user-management/services/api/listBulletResources";

export { LIST_BULLET_RESOURCES_QUERY_KEY };

export function useListBulletResources() {
  const { data, isLoading, isFetching, refetch } = useQuery({
    queryKey: LIST_BULLET_RESOURCES_QUERY_KEY,
    queryFn: fetchListBulletResources,
  });

  return {
    resources: data ?? [],
    loading: isLoading || isFetching,
    refetch,
  };
}
