支付流程重新设计枚举值更新传参方式
This commit is contained in:
@@ -1,41 +1,35 @@
|
||||
'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'
|
||||
import {TradePlatform} from '@/lib/models/trade'
|
||||
import {Dialog} from '@/components/ui/dialog'
|
||||
import {PaymentProps} from './type'
|
||||
|
||||
export function PaymentModal({
|
||||
open,
|
||||
onOpenChange,
|
||||
trade,
|
||||
platform,
|
||||
onSuccess,
|
||||
}: {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
trade: Trade
|
||||
platform: Platform
|
||||
export type PaymentModalProps = {
|
||||
onSuccess?: () => void
|
||||
}) {
|
||||
onClose?: () => void
|
||||
} & PaymentProps
|
||||
|
||||
export function PaymentModal(props: PaymentModalProps) {
|
||||
const handleClose = (success: boolean) => {
|
||||
onOpenChange(false)
|
||||
if (success && onSuccess) {
|
||||
onSuccess()
|
||||
if (success && props.onSuccess) {
|
||||
props.onSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
{platform === Platform.Mobile ? (
|
||||
<Dialog
|
||||
defaultOpen={true}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) props.onClose?.()
|
||||
}}>
|
||||
{props.platform === TradePlatform.Mobile ? (
|
||||
<MobilePayment
|
||||
trade={trade}
|
||||
onClose={() => handleClose(true)}
|
||||
{...props}
|
||||
/>
|
||||
) : (
|
||||
<DesktopPayment
|
||||
trade={trade}
|
||||
onClose={() => handleClose(true)}
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user