/** * Pricing Table Component * Display subscription plans in a table format */ import { useState } from 'react'; import { CheckIcon } from '../../../icons'; import Button from '../button/Button'; export interface PricingPlan { id: number; name: string; monthlyPrice: number; price: number; originalPrice?: number; period: string; description: string; features: string[]; buttonText: string; highlighted?: boolean; disabled?: boolean; annualDiscountPercent?: number; // Plan limits max_sites?: number; max_users?: number; max_keywords?: number; max_ahrefs_queries?: number; included_credits?: number; } interface PricingTableProps { variant?: '1' | '2'; title?: string; plans: PricingPlan[]; showToggle?: boolean; onPlanSelect?: (plan: PricingPlan) => void; } export function PricingTable({ variant = '1', title, plans, showToggle = false, onPlanSelect }: PricingTableProps) { const [billingPeriod, setBillingPeriod] = useState<'monthly' | 'annual'>('monthly'); const getPrice = (plan: PricingPlan) => { if (billingPeriod === 'annual') { const discount = plan.annualDiscountPercent || 20; return (plan.monthlyPrice * 12 * (100 - discount) / 100).toFixed(0); } return plan.monthlyPrice.toFixed(0); }; const getPeriod = () => { return billingPeriod === 'annual' ? '/year' : '/month'; }; return (
{plan.description}
Billed ${(plan.monthlyPrice * 12 * (100 - (plan.annualDiscountPercent || 20)) / 100).toFixed(0)}/year
)}