import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import SEOHead from '@/components/seo/SEOHead';
import { generateWebPage } from '@/utils/seo';
import { Check, X, Zap, Crown, Loader2 } from 'lucide-react';
import axios from 'axios';
import { useAuthStore } from '@/stores/authStore';
import SocialProofStrip from '@/components/shared/SocialProofStrip';
const API_BASE = import.meta.env.VITE_API_URL || '';
interface PlanFeature {
key: string;
free: boolean | string;
pro: boolean | string;
}
const FEATURES: PlanFeature[] = [
{ key: 'webRequests', free: '50/month', pro: '500/month' },
{ key: 'apiAccess', free: false, pro: true },
{ key: 'apiRequests', free: '—', pro: '1,000/month' },
{ key: 'maxFileSize', free: '50 MB', pro: '100 MB' },
{ key: 'historyRetention', free: '25 files', pro: '250 files' },
{ key: 'allTools', free: true, pro: true },
{ key: 'aiTools', free: true, pro: true },
{ key: 'priorityProcessing', free: false, pro: true },
{ key: 'noAds', free: false, pro: true },
{ key: 'emailSupport', free: false, pro: true },
];
export default function PricingPage() {
const { t } = useTranslation();
const user = useAuthStore((s) => s.user);
const [loading, setLoading] = useState(false);
async function handleUpgrade(billing: 'monthly' | 'yearly') {
if (!user) {
window.location.href = '/account?redirect=pricing';
return;
}
setLoading(true);
try {
const { data } = await axios.post(
`${API_BASE}/api/stripe/create-checkout-session`,
{ billing },
{ withCredentials: true },
);
if (data.url) window.location.href = data.url;
} catch {
// Stripe not configured yet — show message
alert(t('pages.pricing.stripeNotReady', 'Payment system is being set up. Please try again later.'));
} finally {
setLoading(false);
}
}
function renderValue(val: boolean | string) {
if (val === true) return
{t('pages.pricing.subtitle', 'Start free with all tools. Upgrade when you need more power.')}
{t('pages.pricing.freeDesc', 'For personal use')}
{t('pages.pricing.proDesc', 'For professionals & teams')}
{t('pages.pricing.securePayment', 'Secure payment via Stripe')}
{t('pages.pricing.trustSubtitle')}
{t('pages.pricing.trustFastDesc')}
{t('pages.pricing.trustPrivateDesc')}
{t('pages.pricing.trustApiDesc')}
| {t('pages.pricing.feature', 'Feature')} | {t('pages.pricing.freePlan', 'Free')} | {t('pages.pricing.proPlan', 'Pro')} |
|---|---|---|
| {t(`pages.pricing.features.${f.key}`, f.key)} | {renderValue(f.free)} | {renderValue(f.pro)} |
{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.')}