import React, { useState, useEffect } from 'react'; import { Check, Loader2, Zap, ArrowRight } from 'lucide-react'; import { apiJson } from '../lib/api'; import Modal from './ui/Modal'; const PLAN_ORDER = ['starter', 'creator', 'pro']; const FREE_MINUTES = 20; const fmt = (a, c) => new Intl.NumberFormat('en-US', { style: 'currency', currency: (c || 'usd').toUpperCase(), maximumFractionDigits: 0 }).format((a || 0) / 100); // Welcome popup after sign-up, instead of dumping the user on the pricing page. // Free is the default (any Google or permanent-email account qualifies), paid // plans check out inline. export default function PlanChoiceModal({ onClose }) { const [plans, setPlans] = useState([]); const [loading, setLoading] = useState(true); const [busy, setBusy] = useState(null); useEffect(() => { apiJson('/api/billing/plans') .then((d) => setPlans(d.plans || [])) .catch(() => setPlans([])) .finally(() => setLoading(false)); }, []); const byPlan = (p) => plans.find((x) => x.plan === p && x.interval === 'month'); const checkout = async (price_id) => { setBusy(price_id); try { const { url } = await apiJson('/api/billing/checkout', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ price_id }), }); window.location.href = url; } catch (e) { setBusy(null); alert(e?.detail || 'Could not start checkout. Please try again.'); } }; const startFree = () => { // A signed-in user with a valid account is already on Free — just start. onClose(); }; return ( {loading ? (
) : (
{/* Free — the default */}

free

$0

try it on your own videos

  • {FREE_MINUTES} min / month
  • No credit card
  • Watermark · clips kept 7 days

no card · start clipping now

{/* Paid — compact list */}

paid plans

no watermark · more minutes · durable library

{PLAN_ORDER.map((p) => { const e = byPlan(p); if (!e) return null; return ( ); })}
)}
); }