import axios from "@/config/axios";
import {
  CategoryResponse,
  DanakServiceSuggestedResponse,
  ServiceDetailResponse,
  ServiceResponse,
  SliderProductResponse,
} from "../types/ProductTypes";

export const getServicesByCategory = async (categoryId?: string) => {
  let query = ``;
  if (categoryId) {
    query = `?categoryId=${categoryId}`;
  }
  const { data } = await axios.get<ServiceResponse>(
    `/danak-services/public${query}`
  );
  return data;
};

export const getCategoriesPublic = async () => {
  const { data } = await axios.get<CategoryResponse>(
    `/danak-services/categories/public`
  );
  return data;
};

export const getDanakServiceSuggested = async () => {
  const { data } = await axios.get<DanakServiceSuggestedResponse>(
    `/danak-services/suggested`
  );
  return data;
};

export const getDetailService = async (serviceId: string) => {
  const { data } = await axios.get<ServiceDetailResponse>(
    `/danak-services/${serviceId}/public`
  );
  return data;
};

export const getSliderProducts = async () => {
  const { data } = await axios.get<SliderProductResponse>(
    `/danak-services/slider`
  );
  return data;
};
