/** * LoginButton — auth entry point for admin controls. * * Shows a LOGIN pill when unauthenticated (opens LoginModal) and a user * dropdown with logout when a session is active. * * Architecture: rendered by App.jsx; uses the useAuth context shared with * InfoBar and RosterManager. * * Design: anonymous users can watch; only admins get controls. */ import { useState } from "react"; import { useAuth } from "../hooks/useAuth"; import LoginModal from "./LoginModal"; export default function LoginButton() { const { user, isAuthenticated, loading, login, logout } = useAuth(); const [showModal, setShowModal] = useState(false); const [showDropdown, setShowDropdown] = useState(false); if (loading) return null; const basePill = { position: "fixed", bottom: 16, right: 16, zIndex: 1500, fontFamily: "'Space Mono', monospace", fontSize: 11, fontWeight: 600, letterSpacing: "0.08em", borderRadius: 6, padding: "7px 16px", cursor: "pointer", display: "flex", alignItems: "center", gap: 7, textTransform: "uppercase", transition: "all 0.15s", }; if (!isAuthenticated) { return ( <> setShowModal(true)} title="Admin login" > LOGIN {showModal && setShowModal(false)} onLogin={login} />} > ); } return ( setShowDropdown((v) => !v)} title="Logged in — click to logout" > {user?.name || user?.email} {showDropdown && ( setShowDropdown(false)} > {user?.email} { setShowDropdown(false); logout(); }} style={{ display: "block", width: "100%", textAlign: "left", padding: "8px 14px", background: "none", border: "none", color: "#ff9494", cursor: "pointer", fontSize: 11, fontFamily: "'Space Mono', monospace", }} > LOGOUT )} ); }