import React, { forwardRef } from "react"; import { PricingSectionProps } from "../../types"; import { Button } from "../ui/Button"; import { Card, CardContent, CardHeader } from "../ui/Card"; import { CardTitle } from "../ui/CardTitle"; // Client Component version - with event handlers export const PricingSection = forwardRef( ( { className = "", title = "Choose Your Plan", subtitle = "Select the perfect plan for your needs", plans = [ { name: "Starter", price: "Free", description: "Perfect for small projects and getting started", features: [ "Basic UI components", "Simple authentication", "Community support", "Basic documentation", ], buttonText: "Get Started", buttonVariant: "outline" as const, }, { name: "Pro", price: "$29", period: "/month", description: "Best for growing teams and serious projects", features: [ "All Starter features", "Advanced components", "Multiple auth providers", "Priority support", "Advanced themes", "Custom integrations", ], highlighted: true, buttonText: "Start Free Trial", buttonVariant: "primary" as const, }, { name: "Enterprise", price: "Custom", description: "For large organizations with specific needs", features: [ "All Pro features", "Custom development", "Dedicated support", "SLA guarantee", "On-premise deployment", "Training sessions", ], buttonText: "Contact Sales", buttonVariant: "secondary" as const, }, ], children, ...props }, ref ) => { return (

{title}

{subtitle && (

{subtitle}

)}
{plans.map((plan, index) => ( {plan.highlighted && (
Most Popular
)} {plan.name}
{plan.price} {plan.period && ( {plan.period} )}

{plan.description}

    {plan.features.map((feature, featureIndex) => (
  • {feature}
  • ))}
))}
{children}
); } ); PricingSection.displayName = "PricingSection"; // Server Component version - with href instead of onButtonClick type ServerPricingPlan = Omit< NonNullable[0], "onButtonClick" > & { buttonHref?: string; buttonTarget?: "_self" | "_blank"; }; type ServerPricingSectionProps = Omit< PricingSectionProps, "plans" | "onBillingChange" > & { plans?: ServerPricingPlan[]; }; export const PricingSectionServer = forwardRef< HTMLElement, ServerPricingSectionProps >( ( { className = "", title = "Choose Your Plan", subtitle = "Select the perfect plan for your needs", plans = [ { name: "Starter", price: "Free", description: "Perfect for small projects and getting started", features: [ "Basic UI components", "Simple authentication", "Community support", "Basic documentation", ], buttonText: "Get Started", buttonVariant: "outline" as const, buttonHref: "/signup", }, { name: "Pro", price: "$29", period: "/month", description: "Best for growing teams and serious projects", features: [ "All Starter features", "Advanced components", "Multiple auth providers", "Priority support", "Advanced themes", "Custom integrations", ], highlighted: true, buttonText: "Start Free Trial", buttonVariant: "primary" as const, buttonHref: "/signup?plan=pro", }, { name: "Enterprise", price: "Custom", description: "For large organizations with specific needs", features: [ "All Pro features", "Custom development", "Dedicated support", "SLA guarantee", "On-premise deployment", "Training sessions", ], buttonText: "Contact Sales", buttonVariant: "secondary" as const, buttonHref: "/contact", }, ], children, ...props }, ref ) => { // Explicitly remove event handlers if they exist in props (runtime safety) // eslint-disable-next-line @typescript-eslint/no-unused-vars const { onBillingChange: _onBillingChange, ...safeProps } = props as Record< string, unknown >; const getButtonClasses = (variant: string = "primary") => { const baseClasses = "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-10 px-4 py-2 w-full"; switch (variant) { case "primary": return `${baseClasses} bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm`; case "secondary": return `${baseClasses} bg-secondary text-secondary-foreground hover:bg-secondary/80`; case "outline": return `${baseClasses} border border-input bg-background hover:bg-accent hover:text-accent-foreground`; default: return `${baseClasses} bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm`; } }; return (

{title}

{subtitle && (

{subtitle}

)}
{plans.map((plan, index) => ( {plan.highlighted && (
Most Popular
)} {plan.name}
{plan.price} {plan.period && ( {plan.period} )}

{plan.description}

    {plan.features.map((feature, featureIndex) => (
  • {feature}
  • ))}
{plan.buttonHref ? ( {plan.buttonText || "Get Started"} ) : (
{plan.buttonText || "Get Started"}
)}
))}
{children}
); } ); PricingSectionServer.displayName = "PricingSectionServer";