diff --git a/components/request/request-page-client.tsx b/components/request/request-page-client.tsx new file mode 100644 index 0000000..c8c27e2 --- /dev/null +++ b/components/request/request-page-client.tsx @@ -0,0 +1,213 @@ +'use client' + +import { useState, useEffect } from 'react' +import { useRouter } from 'next/navigation' +import { + ArrowLeft, + Copy, + Check, + Camera, + AlertCircle, +} from 'lucide-react' +import QRCode from 'react-qr-code' +import { Button } from '@/components/ui/button' +import { QRScanner } from '@/components/send/qr-scanner' +import { cn } from '@/lib/utils' + +interface RequestPageClientProps { + requestId: string +} + +// Mock payment request data — in production, fetch from API +const MOCK_REQUEST = { + id: '123456', + amount: 100, + currency: 'USD', + asset: 'USDC', + description: 'Payment for consulting services', + requesterName: 'John Doe', + requesterWallet: 'GBSN2ZJBRFWTQHWRJQE4GKDJJDSGPVTLQNQCQX7QR5W5VKHNHQH', + createdAt: new Date(Date.now() - 3600000), + expiresAt: new Date(Date.now() + 86400000), +} + +export function RequestPageClient({ requestId }: RequestPageClientProps) { + const router = useRouter() + const [scannerOpen, setScannerOpen] = useState(false) + const [copied, setCopied] = useState(false) + const [isMobile, setIsMobile] = useState(false) + const [scannedAddress, setScannedAddress] = useState(null) + + // Detect mobile viewport + useEffect(() => { + const checkMobile = () => setIsMobile(window.innerWidth < 768) + checkMobile() + window.addEventListener('resize', checkMobile) + return () => window.removeEventListener('resize', checkMobile) + }, []) + + const handleCopyWallet = async () => { + await navigator.clipboard.writeText(MOCK_REQUEST.requesterWallet) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } + + const handleScanPayment = (address: string) => { + // In production, verify the scanned address and process payment + setScannedAddress(address) + setScannerOpen(false) + // TODO: Submit payment confirmation to backend + } + + const qrValue = `stellar:${MOCK_REQUEST.requesterWallet}?amount=${MOCK_REQUEST.amount}&memo=${requestId}` + + return ( +
+
+ {/* ── Header ── */} +
+ +

Payment Request

+
+ +
+ {/* ── Payment amount card ── */} +
+

+ Amount requested +

+
+ + {MOCK_REQUEST.amount} + + + {MOCK_REQUEST.currency} + +
+

+ on Stellar network via {MOCK_REQUEST.asset} +

+
+ + {/* ── Request details ── */} +
+
+

+ Requested by +

+

+ {MOCK_REQUEST.requesterName} +

+
+ {MOCK_REQUEST.description && ( +
+

+ Description +

+

+ {MOCK_REQUEST.description} +

+
+ )} +
+

+ Expires +

+

+ {MOCK_REQUEST.expiresAt.toLocaleString()} +

+
+
+ + {/* ── QR Code card ── */} +
+
+ +
+ +

+ Scan with {MOCK_REQUEST.asset} wallet to pay this request +

+
+ + {/* ── Wallet address ── */} +
+
+

+ Payment address +

+

+ {MOCK_REQUEST.requesterWallet} +

+
+
+ +
+
+ + {/* ── Mobile camera button ── */} + {isMobile && ( + + )} + + {/* ── Scanned address confirmation ── */} + {scannedAddress && ( +
+ +
+

Payment detected

+

+ From: {scannedAddress.slice(0, 10)}...{scannedAddress.slice(-10)} +

+
+
+ )} +
+
+ + {/* ── QR Scanner Modal ── */} + {scannerOpen && ( + setScannerOpen(false)} + /> + )} +
+ ) +} diff --git a/components/send/send-page-client.tsx b/components/send/send-page-client.tsx index 2e430b5..ac281f6 100644 --- a/components/send/send-page-client.tsx +++ b/components/send/send-page-client.tsx @@ -115,7 +115,7 @@ export function SendPageClient() { return (
-
+
{/* ── Header ── */}