"use client"; import { useState } from "react"; import { CreditCard, Zap } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Slider } from "@/components/ui/slider"; import { authClient } from "@/lib/auth-client"; import { TOPUP_PRODUCTS } from "@/lib/polar-products"; import { calculateCustomTopup } from "@/lib/topup-calculator"; import { toast } from "@/lib/toast"; import { msg } from "@/lib/toast-messages"; const CUSTOM_TOPUP_PRODUCT_ID = "POLAR_PRODUCT_ID_TOPUP_CUSTOM"; export function TopupPanel() { const [customAmount, setCustomAmount] = useState(20); const { credits, bonusRate } = calculateCustomTopup(customAmount); async function handleTopup(polarProductId: string) { toast.info( msg.billing.redirectingToCheckout.title, msg.billing.redirectingToCheckout.desc, ); await authClient.checkout({ products: [polarProductId] }); } return (

Quick top-up

{TOPUP_PRODUCTS.map((product) => ( ))}

Custom amount

EUR {customAmount}

{credits.toLocaleString("de-DE")} Cr

{bonusRate > 0 && (

+{Math.round(bonusRate * 100)}% bonus

)}
setCustomAmount(value)} />
EUR 5 EUR 200

Larger amounts include a bonus. Top-ups are always available, even on free plan.

); }