Skip to content

Commit dd7fbf0

Browse files
committed
fix(web): resolve webhook payload mismatch, live demo animation bugs, cleanup EventSource, responsive grid, and dead links
1 parent 918cd3a commit dd7fbf0

2 files changed

Lines changed: 63 additions & 14 deletions

File tree

apps/web/components/LiveDemo.tsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,42 @@ export default function LiveDemo() {
4848
}
4949
}
5050

51-
useEffect(() => () => { esRef.current?.close() }, [])
51+
useEffect(() => {
52+
return () => {
53+
if (esRef.current) {
54+
esRef.current.close()
55+
esRef.current = null
56+
}
57+
}
58+
}, [])
5259

5360
return (
5461
<section style={{ padding: '120px 32px' }}>
62+
63+
{/* ✅ TESTNET NOTICE */}
64+
<div
65+
style={{
66+
maxWidth: 'var(--max-width)',
67+
margin: '0 auto 24px auto',
68+
padding: '12px 16px',
69+
background: '#2a2a00',
70+
border: '1px solid #444400',
71+
color: '#facc15',
72+
fontSize: '13px',
73+
fontFamily: 'var(--font-sans)',
74+
}}
75+
>
76+
⚠️ This demo streams <strong>Stellar testnet</strong> events only. Mainnet
77+
addresses will not produce any events.
78+
</div>
79+
5580
<div
5681
style={{
5782
maxWidth: 'var(--max-width)',
5883
margin: '0 auto',
59-
display: 'grid',
60-
gridTemplateColumns: '1fr 1fr',
61-
gap: '80px',
62-
alignItems: 'start',
6384
}}
64-
className="grid-cols-1 md:grid-cols-[1fr_1fr]"
85+
className="grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-20 items-start"
86+
>
6587
>
6688
{/* Left — text */}
6789
<div>
@@ -224,9 +246,9 @@ export default function LiveDemo() {
224246
</p>
225247
)}
226248
<AnimatePresence initial={false}>
227-
{events.map((ev, i) => (
249+
{events.map((ev) => (
228250
<motion.div
229-
key={i}
251+
key={`${ev.type}-${ev.timestamp}`}
230252
initial={{ opacity: 0, x: -8 }}
231253
animate={{ opacity: 1, x: 0 }}
232254
transition={{ duration: 0.2 }}

apps/web/components/WebhookDemo.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,51 @@ export default function WebhookDemo() {
3131
const [loading, setLoading] = useState(false)
3232

3333
async function handleRegister() {
34-
if (!stellarAddress.trim() || !webhookUrl.trim()) return
34+
if (!stellarAddress.trim() || !webhookUrl.trim()) {
35+
setResponse({
36+
ok: false,
37+
body: 'Address and webhook URL are required',
38+
})
39+
return
40+
}
41+
42+
if (!signingSecret.trim()) {
43+
setResponse({
44+
ok: false,
45+
body: 'Signing secret is required',
46+
})
47+
return
48+
}
49+
3550
setLoading(true)
3651
setResponse(null)
3752

3853
try {
3954
const res = await fetch(`${SERVER}/webhooks/register`, {
4055
method: 'POST',
4156
headers: { 'Content-Type': 'application/json' },
57+
58+
// ✅ MUST match server contract (apps/server/src/routes.ts)
4259
body: JSON.stringify({
4360
address: stellarAddress.trim(),
44-
webhookUrl: webhookUrl.trim(),
45-
signingSecret: signingSecret.trim() || undefined,
61+
url: webhookUrl.trim(),
62+
secret: signingSecret.trim(),
4663
}),
4764
})
48-
const data = await res.json()
65+
66+
const data = await res.json().catch(() => null)
67+
68+
if (!res.ok) {
69+
setResponse({
70+
ok: false,
71+
status: res.status,
72+
body: data?.error || 'Webhook registration failed',
73+
})
74+
return
75+
}
76+
4977
setResponse({
50-
ok: res.ok,
78+
ok: true,
5179
status: res.status,
5280
body: JSON.stringify(data, null, 2),
5381
})
@@ -60,7 +88,6 @@ export default function WebhookDemo() {
6088
setLoading(false)
6189
}
6290
}
63-
6491
return (
6592
<section style={{ padding: '120px 32px' }}>
6693
<div

0 commit comments

Comments
 (0)