import { useRef, useState } from "react"; import { BarChart3, Home, LogOut, Search, Settings, Shield, Tv } from "lucide-react"; import type { FeedFilters, Me } from "../lib/api"; import type { Page } from "../lib/urlState"; import SyncStatus from "./SyncStatus"; import NotificationCenter from "./NotificationCenter"; import AvatarImg from "./Avatar"; export default function Header({ me, filters, setFilters, page, setPage, onOpenSettings, }: { me: Me; filters: FeedFilters; setFilters: (f: FeedFilters) => void; page: Page; setPage: (p: Page) => void; onOpenSettings: () => void; }) { async function logout() { await fetch("/auth/logout", { method: "POST", credentials: "include" }); location.reload(); } return ( setPage("feed")} className="text-xl font-bold tracking-tight select-none" title="Feed" > Subfeed {page === "feed" ? ( setFilters({ ...filters, q: e.target.value })} placeholder="Search your subscriptions…" className="w-full bg-card border border-border rounded-full pl-9 pr-4 py-2 text-sm outline-none focus:border-accent" /> ) : ( {page === "stats" ? "Usage & stats" : "Channel manager"} )} ); } function Avatar({ me, className = "" }: { me: Me; className?: string }) { return ( ); } function AccountMenu({ me, logout, page, setPage, onOpenSettings, }: { me: Me; logout: () => void; page: Page; setPage: (p: Page) => void; onOpenSettings: () => void; }) { const [open, setOpen] = useState(false); const closeTimer = useRef | null>(null); function openNow() { if (closeTimer.current) clearTimeout(closeTimer.current); setOpen(true); } function closeSoon() { closeTimer.current = setTimeout(() => setOpen(false), 220); } const itemClass = "w-full flex items-center gap-2 text-sm px-2 py-2 rounded-lg text-muted hover:text-fg hover:bg-card transition"; return ( setOpen((o) => !o)} title={me.email} className="block rounded-full ring-2 ring-transparent hover:ring-border focus:outline-none focus:ring-accent transition" > {open && ( {me.display_name ?? me.email.split("@")[0]} {me.email} {me.role === "admin" && ( Admin )} {page !== "feed" && ( { setPage("feed"); setOpen(false); }} className={itemClass}> Feed )} {page !== "channels" && ( { setPage("channels"); setOpen(false); }} className={itemClass}> Channels )} {me.role === "admin" && page !== "stats" && ( { setPage("stats"); setOpen(false); }} className={itemClass}> Stats )} { onOpenSettings(); setOpen(false); }} className={itemClass}> Settings Sign out )} ); }