'use client'; import { createClient } from "@/lib/supabase/client"; import { useEffect, useState } from "react"; import { cn } from "@/lib/utils"; import { motion } from "motion/react"; import { setupNewSubscription } from "@/lib/actions/billing"; import { SubmitButton } from "@/components/ui/submit-button"; import { Button } from "@/components/ui/button"; export const SUBSCRIPTION_PLANS = { FREE: 'price_1RDQbOG6l1KZGqIrgrYzMbnL', BASIC: 'price_1RC2PYG6l1KZGqIrpbzFB9Lp', PRO: 'price_1RDQWqG6l1KZGqIrChli4Ys4' } as const; // Custom pricing data with cloud prices const cloudPricingItems = [ { name: "Free", price: "$0", description: "For individual use and exploration", buttonText: "Get Started", buttonColor: "bg-primary text-white", isPopular: false, hours: "1 hour", features: [ "1 hour usage per month", "Basic features", "Community support", "Single user", "Standard response time", "Public templates only", ], }, { name: "Basic", price: "$10", description: "For professionals and small teams", buttonText: "Upgrade Now", buttonColor: "bg-black text-white dark:bg-white dark:text-black", isPopular: true, hours: "10 hours", features: [ "10 hours usage per month", "Priority support", "Advanced features", "3 team members", "Custom integrations", "API access", ], }, { name: "Pro", price: "$50", description: "For organizations with complex needs", buttonText: "Upgrade Now", buttonColor: "bg-primary text-white", isPopular: false, hours: "100 hours", features: [ "100 hours usage per month", "Dedicated support", "SSO & advanced security", "10 team members", "Service level agreement", "Custom AI model training", ], }, ]; interface PlanComparisonProps { accountId?: string | null; returnUrl?: string; isManaged?: boolean; onPlanSelect?: (planId: string) => void; className?: string; } // Price display animation component const PriceDisplay = ({ tier }: { tier: typeof cloudPricingItems[number] }) => { return ( {tier.price} ); }; export function PlanComparison({ accountId, returnUrl = typeof window !== 'undefined' ? window.location.href : '', isManaged = true, onPlanSelect, className = "" }: PlanComparisonProps) { const [currentPlanId, setCurrentPlanId] = useState(); useEffect(() => { async function fetchCurrentPlan() { if (accountId) { const supabase = createClient(); const { data } = await supabase .schema('basejump') .from('billing_subscriptions') .select('price_id') .eq('account_id', accountId) .eq('status', 'active') .single(); setCurrentPlanId(data?.price_id || SUBSCRIPTION_PLANS.FREE); } else { setCurrentPlanId(SUBSCRIPTION_PLANS.FREE); } } fetchCurrentPlan(); }, [accountId]); return (
{cloudPricingItems.map((tier) => { const isCurrentPlan = currentPlanId === SUBSCRIPTION_PLANS[tier.name.toUpperCase() as keyof typeof SUBSCRIPTION_PLANS]; return (

{tier.name}

{tier.isPopular && ( Popular )} {isCurrentPlan && ( Current Plan )}
{tier.price !== "$0" ? "/month" : ""}

{tier.description}

{tier.hours}/month
{!isCurrentPlan && accountId && (
{isManaged ? ( {tier.buttonText} ) : ( )}
)}
{tier.name !== "Free" && (

Everything in {tier.name === "Basic" ? "Free" : "Basic"} +

)}
    {tier.features.map((feature) => (
  • {feature}
  • ))}
); })}
); }