()
| 14 | import { trackUpgrade } from '@/lib/trackConversions' |
| 15 | |
| 16 | function PaymentSuccessContent() { |
| 17 | const searchParams = useSearchParams() ?? new URLSearchParams() |
| 18 | const credits = searchParams.get('amt') |
| 19 | const router = useRouter() |
| 20 | const success = searchParams.get('success') |
| 21 | const canceled = searchParams.get('canceled') |
| 22 | |
| 23 | const { |
| 24 | handleToggleAutoTopup, |
| 25 | handleThresholdChange, |
| 26 | handleTopUpAmountChange, |
| 27 | isEnabled: isAutoTopupEnabled, |
| 28 | } = useAutoTopup() |
| 29 | |
| 30 | const enableMinimumAutoTopup = async () => { |
| 31 | const { DEFAULT_THRESHOLD_CREDITS, DEFAULT_TOPUP_DOLLARS } = |
| 32 | AUTO_TOPUP_CONSTANTS |
| 33 | |
| 34 | await handleToggleAutoTopup(true) |
| 35 | handleThresholdChange(DEFAULT_THRESHOLD_CREDITS) |
| 36 | handleTopUpAmountChange(DEFAULT_TOPUP_DOLLARS) |
| 37 | } |
| 38 | |
| 39 | useEffect(() => { |
| 40 | if (success) { |
| 41 | trackUpgrade(true) |
| 42 | toast({ |
| 43 | title: 'Success!', |
| 44 | description: 'Your payment was successful.', |
| 45 | }) |
| 46 | } |
| 47 | if (canceled) { |
| 48 | toast({ |
| 49 | title: 'Payment canceled', |
| 50 | description: 'Your payment was canceled.', |
| 51 | variant: 'destructive', |
| 52 | }) |
| 53 | router.push('/pricing') |
| 54 | } |
| 55 | }, [success, canceled, router]) |
| 56 | |
| 57 | return ( |
| 58 | <div className="space-y-8"> |
| 59 | <Card className="w-full max-w-2xl mx-auto relative"> |
| 60 | <CardContent className="space-y-6 pt-6"> |
| 61 | <div className="space-y-4"> |
| 62 | <div className="flex items-center justify-between"> |
| 63 | <h3 className="text-lg font-semibold"> |
| 64 | {credits |
| 65 | ? `${Number(credits).toLocaleString()} Credits Added!` |
| 66 | : 'Payment Successful!'} |
| 67 | </h3> |
| 68 | </div> |
| 69 | <p className="text-sm text-muted-foreground"> |
| 70 | Never run out of credits by enabling auto top-up |
| 71 | </p> |
| 72 | <AutoTopupSettings /> |
| 73 |
nothing calls this directly
no test coverage detected