'use client'; import { useMemo, useState } from 'react'; import { createCheckoutSession } from '@/lib/licenseServer'; type Plan = { code: string; name: string; price: string; period: string; description: string; savings?: string | null; highlighted?: boolean; features: string[]; }; export default function PricingCards() { const [loadingPlan, setLoadingPlan] = useState(null); const [error, setError] = useState(null); const plans = useMemo(() => [ { code: 'free', name: 'Free', price: '$0', period: 'forever', description: 'Everything you need to self-host DashCaddy for core use.', features: [ 'Dashboard and monitoring', 'Container deployment', 'Caddy management', 'DNS management', 'Health checks', 'App templates' ] }, { code: 'premium_1m', name: 'Premium, 1 Month', price: '$25', period: 'per month', description: 'Premium feature access for one month.', features: [ 'Auto-Login SSO', 'Recipes (multi-container stack deployment)', 'Docker Swarm orchestration' ] }, { code: 'premium_3m', name: 'Premium, 3 Months', price: '$50', period: 'every 3 months', savings: 'Best short-term value', description: 'A better value plan for regular use.', highlighted: true, features: [ 'Auto-Login SSO', 'Recipes (multi-container stack deployment)', 'Docker Swarm orchestration' ] }, { code: 'premium_6m', name: 'Premium, 6 Months', price: '$65', period: 'every 6 months', savings: 'Strong loyalty pricing', description: 'The commitment plan with aggressive value.', features: [ 'Auto-Login SSO', 'Recipes (multi-container stack deployment)', 'Docker Swarm orchestration' ] }, { code: 'premium_12m', name: 'Premium, 12 Months', price: '$99', period: 'per year', savings: 'Best overall value', description: 'The best-value annual Premium plan.', features: [ 'Auto-Login SSO', 'Recipes (multi-container stack deployment)', 'Docker Swarm orchestration' ] } ], []); async function handleCheckout(planCode: string) { try { setError(null); setLoadingPlan(planCode); const result = await createCheckoutSession(planCode); window.location.href = result.url; } catch (err) { setError(err instanceof Error ? err.message : 'Unable to start checkout'); } finally { setLoadingPlan(null); } } return (
{error && (
{error}
)}
{plans.map((plan) => { const isFree = plan.code === 'free'; const isLoading = loadingPlan === plan.code; return (
{plan.highlighted && (
Recommended
)}

{plan.name}

{plan.description}

{plan.price} /{plan.period}
{plan.savings &&

{plan.savings}

}
{isFree ? ( Use Free Tier ) : ( )}
    {plan.features.map((feature) => (
  • {feature}
  • ))}
); })}
); }