- Plan free resuelto en metering (sin fila Stripe): 20 min/mes para cuentas Google, período sintético de mes natural con reset automático - TRIAL_DAYS=0 para nuevos checkouts; trials en curso grandfathered - Watermark drawtext en clips free (pasada única post-render, sobrevive subtítulos/hooks); thumbnails IA solo de pago - Anti-abuso: 3 jobs/día por cuenta, 5 por IP, rate-limit de probes, contador mensual de GB de proxy con alerta Telegram a 100 GB - Clips free caducan a 7 días (purge_free_expired); purge_expired respeta a cancelados que ahora son free - Galería UGC pública pasa a opt-in (share_to_gallery, antes publicaba producto+guion de todos los usuarios sin permiso) - Emails: clips listos (con star-ask) y sin-minutos (cooldown 24h) - Frontend: card Free en pricing, copy sin trial (landing/legal/gates), StarBanner en resultados y TopUpModal, upsell de watermark
62 lines
2.6 KiB
JavaScript
62 lines
2.6 KiB
JavaScript
import React, { useState, useRef, useEffect } from 'react';
|
|
import { CreditCard, LogOut, Sparkles } from 'lucide-react';
|
|
import { useAuth } from '../contexts/AuthContext';
|
|
|
|
// Header avatar + dropdown for signed-in cloud users: shows the email and gives
|
|
// access to Account & billing (manage subscription, top-ups) and Sign out.
|
|
export default function ProfileMenu() {
|
|
const { user, isManaged, logout } = useAuth();
|
|
const [open, setOpen] = useState(false);
|
|
const ref = useRef(null);
|
|
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
const onClick = (e) => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); };
|
|
document.addEventListener('mousedown', onClick);
|
|
return () => document.removeEventListener('mousedown', onClick);
|
|
}, [open]);
|
|
|
|
if (!user) return null;
|
|
const initial = (user.email || '?').trim().charAt(0).toUpperCase();
|
|
|
|
return (
|
|
<div className="relative" ref={ref}>
|
|
<button
|
|
onClick={() => setOpen((v) => !v)}
|
|
aria-label="Account menu"
|
|
className="w-8 h-8 rounded-full bg-paper3 border border-rule hover:border-rule2 text-brass flex items-center justify-center text-sm font-medium transition-colors"
|
|
>
|
|
{initial}
|
|
</button>
|
|
|
|
{open && (
|
|
<div className="card absolute right-0 top-full mt-2 w-56 z-30 shadow-none overflow-hidden animate-fade">
|
|
<div className="px-4 py-3 border-b border-rule">
|
|
<p className="eyebrow">Signed in as</p>
|
|
<p className="text-sm text-ink truncate mt-0.5" title={user.email}>{user.email}</p>
|
|
</div>
|
|
{!isManaged && (
|
|
<button
|
|
onClick={() => { setOpen(false); window.location.hash = '#/pricing'; }}
|
|
className="w-full flex items-center gap-3 px-4 py-2.5 text-sm lowercase text-brass hover:bg-paper3 transition-colors"
|
|
>
|
|
<Sparkles size={16} /> Start free
|
|
</button>
|
|
)}
|
|
<button
|
|
onClick={() => { setOpen(false); window.location.hash = '#/account'; }}
|
|
className="w-full flex items-center gap-3 px-4 py-2.5 text-sm lowercase text-ink2 hover:bg-paper3 transition-colors"
|
|
>
|
|
<CreditCard size={16} className="text-muted" /> Account & billing
|
|
</button>
|
|
<button
|
|
onClick={() => { setOpen(false); logout(); }}
|
|
className="w-full flex items-center gap-3 px-4 py-2.5 text-sm lowercase text-ink2 hover:bg-paper3 transition-colors border-t border-rule"
|
|
>
|
|
<LogOut size={16} className="text-muted" /> Sign out
|
|
</button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|