import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/LearningService";
import {
  CreateCategoryLearningType,
  CreateLearningType,
} from "../types/LearningTypes";

export const useGetCategory = () => {
  return useQuery({
    queryKey: ["learning-category"],
    queryFn: api.getCategory,
  });
};

export const useCreateCategory = () => {
  return useMutation({
    mutationFn: (variables: CreateCategoryLearningType) =>
      api.createCategory(variables),
  });
};

export const useCreateLearning = () => {
  return useMutation({
    mutationFn: (variables: CreateLearningType) =>
      api.CreateLearning(variables),
  });
};

export const useGetLearning = () => {
  return useQuery({
    queryKey: ["learnings"],
    queryFn: api.getLearnings,
  });
};
