import { useState } from 'react'; import { Settings, LogOut, ExternalLink, Monitor, Sun, Moon, User, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { Separator } from '@/components/ui/separator'; import { useAuth } from '@/context/AuthContext'; import { useLicense } from '@/context/LicenseContext'; import { apiFetch } from '@/lib/api'; import { toast } from '@/components/ui/toast-store'; import { TierBadge } from './TierBadge'; type Theme = 'light' | 'dark' | 'auto'; interface UserProfileDropdownProps { theme: Theme; setTheme: (theme: Theme) => void; onOpenSettings: () => void; } export function UserProfileDropdown({ theme, setTheme, onOpenSettings }: UserProfileDropdownProps) { const { logout, user, isAdmin } = useAuth(); const { license } = useLicense(); const [billingLoading, setBillingLoading] = useState(false); const openBillingPortal = async () => { setBillingLoading(true); try { const res = await apiFetch('/license/billing-portal', { localOnly: true }); const data = await res.json().catch(() => ({})); if (res.ok && data.url) { window.open(data.url, '_blank'); return; } toast.error(data?.error || data?.message || data?.data?.error || 'Something went wrong.'); } catch { toast.error('Failed to open billing portal.'); } finally { setBillingLoading(false); } }; return ( {/* User Info */}

{user?.username ?? 'admin'}

{user?.role ?? 'admin'} ยท
{/* Navigation Links */}
{license?.status === 'active' && !license?.isLifetime && ( )}
{/* Theme Toggle */}

Theme

{/* Documentation Links */} {/* Logout */}
); }