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

  return {
    fetchAll(data: { category_id: number; per_page: number; page: number; search: string }) {
      return apiFetch('/deals', { query: data })
    },

    fetchProducts(data: {
      category_id: number
      per_page: number
      page: number
      search: string
      have_deals: number
      all: string
    }) {
      return apiFetch('/products', { query: data })
    },

    getProductById(productId: number) {
      return apiFetch(`/products/${productId}`)
    },

    getRelatedProducts(productId: number) {
      return apiFetch(`/related_products/${productId}`)
    },

    getDealByProductId(productId: number) {
      return apiFetch(`/deals/${productId}`)
    },

    getDealDetails(bidDate: string) {
      return apiFetch(`/bids/deal-details/${bidDate}`)
    },

    getSubmissions(dealId: number) {
      return apiFetch(`/submissions/show/${dealId}`)
    },

    getMyDeals(status: string, perPage: number, page: number) {
      return apiFetch('/my-deals', { query: { status, per_page: perPage, page } })
    },

    getMyDeal(id: number) {
      return apiFetch(`/my-deals/${id}`)
    },

    getSlaps(id: number) {
      return apiFetch(`/bids/${id}/get-slaps`)
    },

    getPriceList(id: number) {
      return apiFetch(`/price-list/${id}`)
    },

    getLowestPrice(id: number) {
      return apiFetch(`/bids/${id}/show-slaps`)
    },

    joinBids(data: Record<string, unknown>) {
      return apiFetch('/bids/join', { method: 'POST', body: data })
    },

    updateBids(id: number, data: Record<string, unknown>) {
      return apiFetch(`/bids/${id}/update`, { method: 'POST', body: data })
    },

    getBidDetails(id: number) {
      return apiFetch(`/bids/show/${id}`)
    },

    getOrderPatches(id: number) {
      return apiFetch(`/orders-waiting-patches/${id}`)
    },

    getPatchesDetails(orderId: number) {
      return apiFetch('/patches', { query: { order_id: orderId } })
    },
  }
}
