import { useMutation, useQuery } from "@tanstack/react-query";
import * as api from "../service/SliderService";
import { CreateSliderType } from "../types/SliderTypes";
export const useCreateSlider = () => {
  return useMutation({
    mutationFn: api.createSlider,
  });
};

export const useGetSliders = () => {
  return useQuery({
    queryKey: ["sliders"],
    queryFn: api.getSliders,
  });
};

export const useGetSliderDetail = (id: string) => {
  return useQuery({
    queryKey: ["slider-detail", id],
    queryFn: () => api.getSliderDetail(id),
  });
};

export const useUpdateSlider = () => {
  return useMutation({
    mutationFn: (params: { id: string; data: CreateSliderType }) =>
      api.updateSlider(params.id, params.data),
  });
};

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