import { apiClient } from '@/shared/api/client'
import type { CatalogSliderSlide, AdminCatalogSliderSlide } from '../model/types'

export async function fetchCatalogSlider(): Promise<{ slides: CatalogSliderSlide[] }> {
  const { data } = await apiClient.get<{ slides: CatalogSliderSlide[] }>('catalog-slider')
  return data
}

export async function fetchAdminCatalogSlider(): Promise<{ slides: AdminCatalogSliderSlide[] }> {
  const { data } = await apiClient.get<{ slides: AdminCatalogSliderSlide[] }>('admin/catalog-slider')
  return data
}

export async function putAdminCatalogSlider(body: {
  slides: Array<{ galleryImageId: string; caption: string }>
}): Promise<{ slides: AdminCatalogSliderSlide[] }> {
  const { data } = await apiClient.put<{ slides: AdminCatalogSliderSlide[] }>('admin/catalog-slider', body)
  return data
}
