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

export const useGetServicesByCategory = (categoryId?: string) =>
  useQuery({
    queryKey: ["services", categoryId],
    queryFn: () => api.getServicesByCategory(categoryId),
  });

export const useGetDanakServiceSuggested = () =>
  useQuery({
    queryKey: ["danak-service-suggested"],
    queryFn: () => api.getDanakServiceSuggested(),
  });

export const servicesQueryOptions = {
  queryKey: ["services", ""],
  queryFn: () => api.getServicesByCategory(undefined),
};

export const danakServiceSuggestedQueryOptions = {
  queryKey: ["danak-service-suggested"],
  queryFn: () => api.getDanakServiceSuggested(),
};

export const useGetCategories = () =>
  useQuery({
    queryKey: ["service-categories"],
    queryFn: () => api.getCategoriesPublic(),
  });

export const useGetSliderProducts = () =>
  useQuery({
    queryKey: ["slider-products"],
    queryFn: () => api.getSliderProducts(),
  });

export const categoriesQueryOptions = {
  queryKey: ["service-categories"],
  queryFn: () => api.getCategoriesPublic(),
};

export const sliderProductsQueryOptions = {
  queryKey: ["slider-products"],
  queryFn: () => api.getSliderProducts(),
};

export const useGetDetailService = (serviceId: string) =>
  useQuery({
    queryKey: ["service-detail", serviceId],
    queryFn: () => api.getDetailService(serviceId),
  });

export const detailServiceQueryOptions = (serviceId: string) => ({
  queryKey: ["service-detail", serviceId],
  queryFn: () => api.getDetailService(serviceId),
});
