'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"; import { siteConfig } from "@/lib/home"; export const SUBSCRIPTION_PLANS = { FREE: 'price_1RDQbOG6l1KZGqIrgrYzMbnL', BASIC: 'price_1RC2PYG6l1KZGqIrpbzFB9Lp', PRO: 'price_1RDQWqG6l1KZGqIrChli4Ys4' } as const; interface PlanComparisonProps { accountId?: string | null; returnUrl?: string; isManaged?: boolean; onPlanSelect?: (planId: string) => void; className?: string; } // Price display animation component const PriceDisplay = ({ tier }: { tier: typeof siteConfig.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 (
{siteConfig.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}
  • ))}
); })}
); }