forked from MergeFi/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuccessScreen.tsx
More file actions
152 lines (140 loc) · 5.03 KB
/
Copy pathSuccessScreen.tsx
File metadata and controls
152 lines (140 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import React from 'react'
import { CheckCircle2, ExternalLink, Copy, Send, RotateCcw, Check } from 'lucide-react'
import { Link } from 'react-router-dom'
import { Button } from '@/components/ui/Button'
import { Card } from '@/components/ui/Card'
import { copyToClipboard } from '@/lib/utils'
import { formatAmount } from '@/lib/stellar'
import type { SendPaymentResult, Quote } from '@/types'
import { useState } from 'react'
interface SuccessScreenProps {
result: SendPaymentResult
quote: Quote
network: 'testnet' | 'mainnet'
onSendAnother: () => void
}
export function SuccessScreen({ result, quote, network, onSendAnother }: SuccessScreenProps) {
const [copied, setCopied] = useState(false)
const explorerUrl =
network === 'testnet'
? `https://stellar.expert/explorer/testnet/tx/${result.transactionHash}`
: `https://stellar.expert/explorer/public/tx/${result.transactionHash}`
const handleCopy = async () => {
await copyToClipboard(result.transactionHash)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
}
return (
<div className="space-y-6 animate-fade-in">
{/* Success hero */}
<div className="flex flex-col items-center text-center py-8">
<div className="relative mb-6">
{/* Outer ring */}
<div className="w-28 h-28 rounded-full bg-success-500/10 border-2 border-success-500/30 flex items-center justify-center">
{/* Inner circle */}
<div className="w-20 h-20 rounded-full bg-success-500/20 border border-success-500/40 flex items-center justify-center">
<CheckCircle2 size={44} className="text-success-400" />
</div>
</div>
{/* Glow */}
<div className="absolute inset-0 rounded-full bg-success-500/5 animate-pulse-slow" />
</div>
<h2 className="text-2xl font-bold text-white mb-2">Payment Sent!</h2>
<p className="text-slate-400 max-w-xs">
Your transaction has been confirmed on the Stellar network.
</p>
</div>
{/* Summary card */}
<Card>
<div className="space-y-3">
<div className="text-center pb-3 border-b border-navy-700/50">
<p className="text-3xl font-bold text-stellar-400 tabular-nums">
{formatAmount(quote.sendAmount, 4)}
</p>
<p className="text-sm text-slate-400 mt-1">{quote.sourceAsset.code} sent</p>
</div>
<SummaryRow label="Recipient received">
<span className="font-semibold text-success-400 tabular-nums">
{formatAmount(quote.receiveAmount, 4)} {quote.destinationAsset.code}
</span>
</SummaryRow>
<SummaryRow label="Network fee">
<span className="text-slate-300">
{formatAmount(result.fee, 7)} XLM
</span>
</SummaryRow>
<SummaryRow label="Ledger">
<span className="text-slate-300 font-mono">
#{result.ledger.toLocaleString()}
</span>
</SummaryRow>
<SummaryRow label="Confirmed at">
<span className="text-slate-300">
{new Date(result.createdAt).toLocaleString()}
</span>
</SummaryRow>
</div>
</Card>
{/* Transaction hash */}
<Card padding="sm">
<p className="text-xs text-slate-400 mb-2 font-medium">Transaction Hash</p>
<div className="flex items-center gap-2 p-2.5 rounded-lg bg-navy-900/60 border border-navy-700/40">
<span className="text-xs font-mono text-slate-300 flex-1 break-all">
{result.transactionHash}
</span>
<button
onClick={handleCopy}
className="p-1.5 rounded-lg hover:bg-white/5 text-slate-400 hover:text-white transition-colors shrink-0"
title="Copy hash"
>
{copied ? (
<Check size={13} className="text-success-400" />
) : (
<Copy size={13} />
)}
</button>
</div>
</Card>
{/* Actions */}
<div className="flex flex-col gap-3">
<Button
variant="outline"
fullWidth
icon={<ExternalLink size={15} />}
onClick={() => window.open(explorerUrl, '_blank', 'noopener')}
>
View on Stellar Explorer
</Button>
<div className="flex gap-3">
<Button
variant="secondary"
fullWidth
icon={<RotateCcw size={14} />}
onClick={onSendAnother}
>
Send Another
</Button>
<Link to="/history" className="flex-1">
<Button variant="ghost" fullWidth icon={<Send size={14} />}>
View History
</Button>
</Link>
</div>
</div>
</div>
)
}
function SummaryRow({
label,
children,
}: {
label: string
children: React.ReactNode
}) {
return (
<div className="flex items-center justify-between gap-3 text-sm">
<span className="text-slate-400">{label}</span>
{children}
</div>
)
}