44 lines
927 B
TypeScript
44 lines
927 B
TypeScript
'use client'
|
|
import {Dialog} from '@/components/ui/dialog'
|
|
import {MobilePayment} from './mobile-payment'
|
|
import {DesktopPayment} from './desktop-payment'
|
|
import {Platform} from '@/lib/models/trade'
|
|
import {Trade} from './types'
|
|
|
|
export function PaymentModal({
|
|
open,
|
|
onOpenChange,
|
|
trade,
|
|
platform,
|
|
onSuccess,
|
|
}: {
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
trade: Trade
|
|
platform: Platform
|
|
onSuccess?: () => void
|
|
}) {
|
|
const handleClose = (success: boolean) => {
|
|
onOpenChange(false)
|
|
if (success && onSuccess) {
|
|
onSuccess()
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
{platform === Platform.Mobile ? (
|
|
<MobilePayment
|
|
trade={trade}
|
|
onClose={() => handleClose(true)}
|
|
/>
|
|
) : (
|
|
<DesktopPayment
|
|
trade={trade}
|
|
onClose={() => handleClose(true)}
|
|
/>
|
|
)}
|
|
</Dialog>
|
|
)
|
|
}
|