MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / UserMenu

Function UserMenu

frontend-workflow/src/components/UserMenu.tsx:21–197  ·  view source on GitHub ↗
({ onShowFiles, onShowAccount }: UserMenuProps = {})

Source from the content-addressed store, hash-verified

19}
20
21export function UserMenu({ onShowFiles, onShowAccount }: UserMenuProps = {}) {
22 const { t } = useTranslation('common');
23 const { user, signOut } = useAuthStore();
24 const { runtimeConfig } = useRuntimeBilling();
25 const [open, setOpen] = useState(false);
26 const ref = useRef<HTMLDivElement>(null);
27
28 // Close on outside click
29 useEffect(() => {
30 const handler = (e: MouseEvent) => {
31 if (ref.current && !ref.current.contains(e.target as Node)) {
32 setOpen(false);
33 }
34 };
35 document.addEventListener("mousedown", handler);
36 return () => document.removeEventListener("mousedown", handler);
37 }, []);
38
39 // Hide when Supabase is not configured or no user
40 if (!isSupabaseConfigured() || !user) return null;
41
42 const displayName = user.email?.split('@')[0] || user.phone?.slice(-4) || t('userMenu.user');
43 const fullEmail = user.email || user.phone || "";
44 const purchaseUrl =
45 runtimeConfig.points_purchase_url?.trim()
46 || getPurchaseUrl(runtimeConfig.managed_api_url || DEFAULT_LLM_API_URL);
47
48 const handleSignOut = async () => {
49 setOpen(false);
50 await signOut();
51 };
52
53 return (
54 <div ref={ref} className="relative z-50">
55 <button
56 onClick={() => setOpen(!open)}
57 className={`group relative flex items-center gap-2 px-1 pl-1.5 pr-3 py-1 rounded-full border transition-all duration-300 ${
58 open
59 ? "bg-white/10 border-white/20 shadow-[0_0_15px_rgba(168,85,247,0.3)]"
60 : "bg-black/20 border-white/10 hover:bg-white/10 hover:border-white/20 hover:shadow-[0_0_10px_rgba(168,85,247,0.15)]"
61 }`}
62 >
63 {/* Avatar / Icon */}
64 <div className="w-8 h-8 rounded-full flex items-center justify-center shadow-inner relative overflow-hidden bg-gradient-to-br from-purple-500/20 to-pink-500/20 border border-purple-500/30">
65 <Crown size={16} className="text-purple-200" />
66
67 {/* Shine effect */}
68 <div className="absolute inset-0 bg-gradient-to-tr from-transparent via-white/10 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500" />
69 </div>
70
71 <div className="flex flex-col items-start mr-1">
72 <span className="text-sm font-medium leading-none bg-gradient-to-r from-purple-200 to-pink-200 bg-clip-text text-transparent group-hover:from-white group-hover:to-white transition-all">
73 {displayName}
74 </span>
75 <span className="text-[10px] text-gray-400 leading-tight scale-90 origin-left">PRO MEMBER</span>
76 </div>
77
78 <ChevronDown

Callers

nothing calls this directly

Calls 3

useRuntimeBillingFunction · 0.90
isSupabaseConfiguredFunction · 0.90
getPurchaseUrlFunction · 0.90

Tested by

no test coverage detected