'use client'

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

export const PAYMENT_LINK_DETAILS_QUERY_KEY = 'payment-link-details'

export const useGetPaymentLinkDetails = (
  linkId?: string,
  options?: CustomUseQueryOptions<IBaseResponse<{ payment_links: IPaymentLink }>>
) => {
  return useCustomQuery<IBaseResponse<{ payment_links: IPaymentLink }>>(
    [PAYMENT_LINK_DETAILS_QUERY_KEY, linkId],
    () =>
      request({
        url: `admin/payment/links/${linkId}`
      }),
    {
      enabled: Boolean(linkId),
      ...options
    }
  )
}
