import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import SEOHead from '@/components/seo/SEOHead';
import { generateWebPage, getSiteOrigin } from '@/utils/seo';
import { ArrowRight, Check, Coins, Crown, Loader2, Scale, Shield, Zap } from 'lucide-react';
import { useAuthStore } from '@/stores/authStore';
import SocialProofStrip from '@/components/shared/SocialProofStrip';
import { getApiClient } from '@/services/api';
const API_BASE = import.meta.env.VITE_API_URL || '';
const api = getApiClient();
interface PlanFeature {
key: string;
free: boolean | string;
pro: boolean | string;
enterprise: boolean | string;
}
const FEATURES: PlanFeature[] = [
{ key: 'credits', free: '50 credits/30 days', pro: '500 credits/30 days', enterprise: 'Unlimited' },
{ key: 'apiAccess', free: false, pro: true, enterprise: true },
{ key: 'apiRequests', free: '—', pro: '1,000/month', enterprise: 'Unlimited' },
{ key: 'maxFileSize', free: '50 MB', pro: '100 MB', enterprise: '500 MB' },
{ key: 'historyRetention', free: '25 files', pro: '250 files', enterprise: 'Unlimited' },
{ key: 'allTools', free: true, pro: true, enterprise: true },
{ key: 'aiTools', free: true, pro: true, enterprise: true },
{ key: 'priorityProcessing', free: false, pro: true, enterprise: true },
{ key: 'noAds', free: false, pro: true, enterprise: true },
{ key: 'emailSupport', free: false, pro: true, enterprise: true },
{ key: 'customIntegrations', free: false, pro: false, enterprise: true },
{ key: 'dedicatedSupport', free: false, pro: false, enterprise: true },
{ key: 'userManagement', free: false, pro: false, enterprise: true },
];
const MONTHLY_PRICES = { free: 0, pro: 9.99, enterprise: 29.99 };
const YEARLY_PRICES = { free: 0, pro: 7.99, enterprise: 24.99 };
export default function PricingPage() {
const { t } = useTranslation();
const siteOrigin = getSiteOrigin(typeof window !== 'undefined' ? window.location.origin : '');
const user = useAuthStore((s) => s.user);
const [loading, setLoading] = useState(false);
const [billing, setBilling] = useState<'monthly' | 'yearly'>('yearly');
async function handleUpgrade(plan: 'pro' | 'enterprise') {
// Track interest in paid plan
try {
await api.post('/internal/admin/plan-interest/record', { plan, billing });
} catch {
// Non-critical — don't block the flow
}
if (plan === 'enterprise') {
window.location.href = '/contact';
return;
}
if (!user) {
window.location.href = '/account?redirect=pricing';
return;
}
setLoading(true);
try {
const { data } = await api.post(`${API_BASE}/stripe/create-checkout-session`, { billing });
if (data.url) window.location.href = data.url;
} catch {
alert(t('pages.pricing.stripeNotReady', 'Payment system is being set up. Please try again later.'));
} finally {
setLoading(false);
}
}
const prices = billing === 'yearly' ? YEARLY_PRICES : MONTHLY_PRICES;
return (
<>
{t('pages.pricing.subtitle', 'Unlock the power of your PDFs with flexible plans.')}
{/* Billing toggle */}{t('pages.pricing.transparencyBody')}
{t('pages.pricing.trustSubtitle')}
{t('pages.pricing.trustFastDesc')}
{t('pages.pricing.trustPrivateDesc')}
{t('pages.pricing.trustApiDesc')}
{t('pages.pricing.faq1a', 'Yes! All 32+ tools are available for free with generous monthly limits. No credit card required.')}
{t('pages.pricing.faq2a', 'Absolutely. Cancel anytime — no questions asked. Your account reverts to the Free plan.')}
{t('pages.pricing.faq3a', 'We accept all major credit/debit cards via Stripe. Your payment information is securely processed — we never see your card details.')}