import { useQuery } from "@tanstack/react-query";
import * as api from "../service/LearningService";

export const useGetLearnings = (search: string, limit?: number) => {
  return useQuery({
    queryKey: ["learnings", search, limit],
    queryFn: () => api.getLearnings(search, limit),
  });
};

export const useGetLearningDetail = (id: string) => {
  return useQuery({
    queryKey: ["learning", id],
    queryFn: () => api.getLearningDetail(id),
    enabled: !!id,
  });
};
