"use client"; import { useState } from "react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import type { Tier } from "@/lib/subscription/config"; export function PricingClient({ currentTier }: { currentTier: Tier }) { const [loading, setLoading] = useState(false); if (currentTier === "pro") { return (

You're on Pro. Manage your subscription through the receipt email link.

); } const upgrade = async () => { setLoading(true); try { const response = await fetch("/api/billing/checkout", { method: "POST" }); const data = await response.json(); if (response.ok && data.url) { window.location.href = data.url; return; } toast.error(data.message ?? "Failed to start checkout"); } catch (error) { toast.error(error instanceof Error ? error.message : "Checkout failed"); } finally { setLoading(false); } }; return (
); }