import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/WarrantyService";
import type { WarrantyResponse } from "../types/Types";

export const useGetWarranties = (page: number = 1, limit: number = 10) => {
  return useQuery<WarrantyResponse>({
    queryKey: ["warranties", page, limit],
    queryFn: () => api.getWarranties({ page, limit }),
  });
};

export const useDeleteWarranty = () => {
  return useMutation({
    mutationFn: (id: string) => api.deleteWarranty(id),
  });
};

export const useCreateWarranty = () => {
  return useMutation({
    mutationFn: api.createWarranty,
  });
};
