'use client'
import {MobilePayment} from './mobile-payment'
import {DesktopPayment} from './desktop-payment'
import {TradePlatform} from '@/lib/models/trade'
import {Dialog} from '@/components/ui/dialog'
import {PaymentProps} from './type'

export type PaymentModalProps = {
  onConfirm?: () => Promise<void>
  onClose?: () => void
} & PaymentProps

export function PaymentModal(props: PaymentModalProps) {
  return (
    <Dialog
      defaultOpen={true}
      onOpenChange={(open) => {
        if (!open) props.onClose?.()
      }}>
      {props.platform === TradePlatform.Mobile ? (
        <MobilePayment
          {...props}
        />
      ) : (
        <DesktopPayment
          {...props}
        />
      )}
    </Dialog>
  )
}
