'use client'

import { IBaseResponse, CustomUseQueryOptions } from '@/@core/types/api'
import { useCustomQuery } from '@/hooks/api'
import { IOrder } from '@/types/data'
import { request } from '@/utils'

export const ORDER_DETAILS_QUERY_KEY = 'order-details'

export const useGetOrderDetails = (orderId?: string, options?: CustomUseQueryOptions<IBaseResponse<IOrder>>) => {
  return useCustomQuery<IBaseResponse<IOrder>>(
    [ORDER_DETAILS_QUERY_KEY, orderId],
    () =>
      request({
        url: `/orders/${orderId}`
      }),
    {
      enabled: Boolean(orderId),
      ...options
    }
  )
}
