2025-06-22 14:42:21 +08:00
|
|
|
'use client'
|
|
|
|
|
import {MobilePayment} from './mobile-payment'
|
|
|
|
|
import {DesktopPayment} from './desktop-payment'
|
2025-06-23 11:20:54 +08:00
|
|
|
import {TradePlatform} from '@/lib/models/trade'
|
|
|
|
|
import {Dialog} from '@/components/ui/dialog'
|
|
|
|
|
import {PaymentProps} from './type'
|
2025-06-22 14:42:21 +08:00
|
|
|
|
2025-06-23 11:20:54 +08:00
|
|
|
export type PaymentModalProps = {
|
2025-06-22 14:42:21 +08:00
|
|
|
onSuccess?: () => void
|
2025-06-23 11:20:54 +08:00
|
|
|
onClose?: () => void
|
|
|
|
|
} & PaymentProps
|
|
|
|
|
|
|
|
|
|
export function PaymentModal(props: PaymentModalProps) {
|
2025-06-22 14:42:21 +08:00
|
|
|
const handleClose = (success: boolean) => {
|
2025-06-23 11:20:54 +08:00
|
|
|
if (success && props.onSuccess) {
|
|
|
|
|
props.onSuccess()
|
2025-06-22 14:42:21 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2025-06-23 11:20:54 +08:00
|
|
|
<Dialog
|
|
|
|
|
defaultOpen={true}
|
|
|
|
|
onOpenChange={(open) => {
|
|
|
|
|
if (!open) props.onClose?.()
|
|
|
|
|
}}>
|
|
|
|
|
{props.platform === TradePlatform.Mobile ? (
|
2025-06-22 14:42:21 +08:00
|
|
|
<MobilePayment
|
2025-06-23 11:20:54 +08:00
|
|
|
{...props}
|
2025-06-22 14:42:21 +08:00
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<DesktopPayment
|
2025-06-23 11:20:54 +08:00
|
|
|
{...props}
|
2025-06-22 14:42:21 +08:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Dialog>
|
|
|
|
|
)
|
|
|
|
|
}
|