'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_1RGJ9GG6l1KZGqIroxSqgphC', BASIC: 'price_1RGJ9LG6l1KZGqIrd9pwzeNW', PRO: 'price_1RGJ9JG6l1KZGqIrVUU4ZRv6' } 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} ) : ( onPlanSelect?.(SUBSCRIPTION_PLANS[tier.name.toUpperCase() as keyof typeof SUBSCRIPTION_PLANS])} > {tier.buttonText} )} )} {tier.name !== "Free" && ( Everything in {tier.name === "Basic" ? "Free" : "Basic"} + )} {tier.features.map((feature) => ( {feature} ))} {(tier as any).showContactSales && ( window.open('mailto:support@kortix.ai?subject=Enterprise Plan Inquiry', '_blank')} > Need more? Contact Sales )} ); })} ); }
{tier.description}
Everything in {tier.name === "Basic" ? "Free" : "Basic"} +