'use client'

import type { IBaseResponse } from '@/@core/types/api'
import { request } from '@/utils'
import { useCustomMutation } from '@/hooks/api'

export type InitiatePaymentPayload = {
  order_id: string
  payment_method_id: string
}

export interface InitiatePaymentResponse {
  payment_url: string
  transaction_id: string
}

export const useInitiatePayment = () => {
  return useCustomMutation<InitiatePaymentPayload, IBaseResponse<InitiatePaymentResponse>>(
    ['orders-initiate-payment'],
    payload =>
      request({
        url: '/payment/initiate',
        method: 'POST',
        data: payload,
        withToken: false
      })
  )
}
