"use client"; import { useState } from "react"; import { useTranslations } from "next-intl"; 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"; const CUSTOM_TOPUP_PRODUCT_ID = "POLAR_PRODUCT_ID_TOPUP_CUSTOM"; export function TopupPanel() { const t = useTranslations('toasts'); const [customAmount, setCustomAmount] = useState(20); const { credits, bonusRate } = calculateCustomTopup(customAmount); async function handleTopup(polarProductId: string) { toast.info( t('billing.redirectingToCheckoutTitle'), t('billing.redirectingToCheckoutDesc'), ); await authClient.checkout({ products: [polarProductId] }); } return (
{credits.toLocaleString("de-DE")} Cr
{bonusRate > 0 && (
Larger amounts include a bonus. Top-ups are always available, even on free plan.