frontend: add LoginGate, wire session into App, add logout link
This commit is contained in:
@@ -5,6 +5,7 @@ import { Dashboard } from "./pages/Dashboard";
|
||||
import { Plan } from "./pages/Plan";
|
||||
import { Profile } from "./pages/Profile";
|
||||
import { ReviewQueue } from "./pages/ReviewQueue";
|
||||
import type { SessionInfo } from "./types/api";
|
||||
|
||||
const TABS = [
|
||||
{ key: "activities", label: "Activities", icon: "☰", Component: ReviewQueue },
|
||||
@@ -14,7 +15,7 @@ const TABS = [
|
||||
|
||||
type TabKey = (typeof TABS)[number]["key"];
|
||||
|
||||
function App() {
|
||||
function App({ session }: { session: SessionInfo }) {
|
||||
const [tab, setTab] = useState<TabKey>("activities");
|
||||
// Profile isn't a tab: it's reached via the profile name in the top-right
|
||||
// corner instead, since (for now, single-profile) it's account settings,
|
||||
@@ -47,13 +48,18 @@ function App() {
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<button
|
||||
type="button"
|
||||
className={showProfile ? "profile-name active" : "profile-name"}
|
||||
onClick={() => setShowProfile(true)}
|
||||
>
|
||||
{profileName ?? "Profile"}
|
||||
</button>
|
||||
<div className="header-actions">
|
||||
<button
|
||||
type="button"
|
||||
className={showProfile ? "profile-name active" : "profile-name"}
|
||||
onClick={() => setShowProfile(true)}
|
||||
>
|
||||
{profileName ?? "Profile"}
|
||||
</button>
|
||||
<a className="logout-link" href="/api/session/logout" title={session.email}>
|
||||
Log out
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<main>{showProfile ? <Profile onSaved={(p) => setProfileName(p.Name)} /> : <Active />}</main>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user