'use client' import { useEffect, useState, Suspense } from 'react' import { useSearchParams, useRouter } from 'next/navigation' import { CheckCircle, Download, ArrowRight, Home, Receipt } from 'lucide-react' import { Button } from '@/components/ui/button' import { Card, CardContent } from '@/components/ui/card' interface PaymentDetails { txn: string amount: string type?: string warning?: string } // Main payment success component with search params handling function PaymentSuccessContent() { const searchParams = useSearchParams() const router = useRouter() const [details, setDetails] = useState(null) const [countdown, setCountdown] = useState(10) useEffect(() => { // Extract payment details from URL parameters const txn = searchParams.get('txn') const amount = searchParams.get('amount') const type = searchParams.get('type') || 'billing' const warning = searchParams.get('warning') if (txn && amount) { setDetails({ txn, amount, type, warning: warning || undefined, }) } // Auto-redirect countdown const timer = setInterval(() => { setCountdown((prev) => { if (prev <= 1) { router.push('/profile') return 0 } return prev - 1 }) }, 1000) return () => clearInterval(timer) }, [searchParams, router]) const handleDashboardRedirect = () => { router.push('/profile') } const handleDownloadReceipt = () => { // TODO: Implement receipt download // In real implementation, this would generate and download a PDF receipt console.log('Downloading receipt for transaction:', details?.txn) alert('Receipt download feature will be implemented') } if (!details) { return (

Loading payment details...

) } return (
{/* Success Icon */}
{/* Success Message */}

Payment Successful!

{details.type === 'balance' ? 'Your account balance has been updated successfully.' : 'Your payment has been processed successfully.'}

{/* Warning Message (if any) */} {details.warning && (

⚠️ Payment successful, but there was an issue updating our records. Our team has been notified and will resolve this shortly.

)} {/* Payment Details */}
Transaction ID {details.txn}
Amount ₹{parseFloat(details.amount).toLocaleString('en-IN', { minimumFractionDigits: 2 })}
Type {details.type === 'balance' ? 'Balance Addition' : 'Service Payment'}
Date {new Date().toLocaleDateString('en-IN', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', })}
{/* Action Buttons */}
{/* Auto-redirect Notice */}

Redirecting to dashboard in {countdown} seconds

{/* Next Steps */}

What's Next?

{details.type === 'balance' ? ( <>

• Your account balance has been updated

• You can now use your balance for services

• Check your transaction history in your profile

) : ( <>

• Your service will be activated shortly

• Check your email for service details

• View service status in your dashboard

)}
) } // Wrapper component with Suspense boundary export default function PaymentSuccessPage() { return (
} >
) }