'use client'

import { IBaseResponse } from '@/@core/types/api'
import { IPaymentMethodDetails, ICreatePaymentMethodPayload } from '@/types/data/payment-method'
import { request } from '@/utils'
import { PAYMENT_METHODS_LIST_QUERY_KEY } from './useGetPaymentMethodsList'
import { useCustomMutation } from '@/hooks/api'

export const useCreatePaymentMethod = () => {
  return useCustomMutation<ICreatePaymentMethodPayload, IBaseResponse<IPaymentMethodDetails>>(
    ['payment-methods-create'],
    payload =>
      request({
        url: '/payment-methods',
        method: 'POST',
        data: payload
      }),
    {
      invalidateQueries: [PAYMENT_METHODS_LIST_QUERY_KEY]
    }
  )
}
