"use client"; import { useQuery } from "convex/react"; import { Check } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { api } from "@/convex/_generated/api"; import { authClient } from "@/lib/auth-client"; import { normalizeTier, SUBSCRIPTION_PRODUCTS, TIER_MONTHLY_CREDITS, } from "@/lib/polar-products"; const TIER_ORDER = ["free", "starter", "pro", "max"] as const; export function PricingCards() { const subscription = useQuery(api.credits.getSubscription); const currentTier = normalizeTier(subscription?.tier); async function handleCheckout(polarProductId: string) { await authClient.checkout({ products: [polarProductId] }); } return (
Free {currentTier === "free" && Current}

EUR 0

{TIER_MONTHLY_CREDITS.free} Credits / month

{(["starter", "pro", "max"] as const).map((tier) => { const product = SUBSCRIPTION_PRODUCTS[tier]; const isCurrent = currentTier === tier; const isUpgrade = TIER_ORDER.indexOf(tier) > TIER_ORDER.indexOf(currentTier); return (
{product.label} {isCurrent && Current} {tier === "pro" && !isCurrent && Popular}

EUR {product.price}

{product.credits.toLocaleString("de-DE")} Credits / month

); })}
); }