export function useProductsService() {
  const { apiFetch } = useApi()

  return {
    getByCategory(categoryId: number, page = 1, search = '', all = '') {
      return apiFetch('/products', {
        query: { category_id: categoryId, per_page: 15, page, search, all },
      })
    },

    getById(id: number) {
      return apiFetch(`/products/${id}`)
    },

    getRating(id: number) {
      return apiFetch(`/products/${id}/rating`)
    },

    getCompanyProducts() {
      return apiFetch('/companies/products')
    },

    uploadFile(data: FormData) {
      return apiFetch('/companies/sync-products-import', {
        method: 'POST',
        body: data,
      })
    },

    updateProducts(data: Record<string, unknown>) {
      return apiFetch('/companies/settings/sync-products', {
        method: 'POST',
        body: data,
      })
    },
  }
}
