Files
sorsfonalak/services/frontend/src/components/SiteHeader.tsx
T
fecoandClaude Opus 5.5 1ab693175e
CI / test (push) Successful in 1m22s
CI / build (push) Successful in 4m46s
CI / deploy (push) Skipped
The visitor header on every public page
The example analysis, shared charts, the invitation page and the privacy
page showed visitors just the logo. They now get the home page's header:
the sections, the example and the login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-19 11:42:02 +00:00

94 lines
2.8 KiB
TypeScript

import Link from "next/link";
import type { Me } from "@/lib/types";
import { LogoutButton } from "./LogoutButton";
import { NavLinks } from "./NavLinks";
export function Logo() {
return (
<Link href="/" className="logo">
sors<span>fonalak</span>
</Link>
);
}
/**
* The header for visitors (not logged in): the home page sections, the
* example and the login. `onHome`: the section links stay on the page.
*/
export function PublicHeader({ onHome = false, current }: { onHome?: boolean; current?: "pelda" }) {
const home = onHome ? "" : "/";
return (
<header className="site-header lp-header">
<Logo />
<nav className="nav lp-nav" aria-label="Fő navigáció">
<a href={`${home}#elemzes`}>Elemzés</a>
<a href={`${home}#elorejelzes`}>Előrejelzés</a>
<a href={`${home}#osszevetes`}>Összevetés</a>
<Link href="/pelda" aria-current={current === "pelda" ? "page" : undefined}>
Példa
</Link>
</nav>
<Link href="/belepes" className="btn btn-sm">
Belépés
</Link>
</header>
);
}
/** The user's package and what is left of it; leads to the packages page. */
function PackageBadge({ me }: { me: Me }) {
const { natal, synastry } = me.analyses_left;
const left = natal + synastry;
let name: string;
let detail: string | null;
if (me.package) {
name = me.package.name;
detail = left > 0 ? `${left} elemzés` : "elfogyott";
} else if (left > 0) {
name = `${left} elemzés`;
detail = null;
} else {
return null;
}
const units = `Képletelemzés: ${natal}, kapcsolati elemzés: ${synastry}`;
const empty = left === 0;
return (
<Link
href="/csomagok"
className={empty ? "pkg-pill pkg-pill-empty" : "pkg-pill"}
title={units}
aria-label={`Csomagod: ${name}${detail ? `, ${detail}` : ""}. ${units}.`}
>
<span className="pkg-pill-name">{name}</span>
{detail && <span className="pkg-pill-detail">{detail}</span>}
</Link>
);
}
export function SiteHeader({ me }: { me: Me }) {
const links = [
{ href: "/keplet", label: "Képletem" },
{ href: "/szemelyek", label: "Személyek" },
{ href: "/osszevetesek", label: "Összevetések" },
{ href: "/csomagok", label: "Csomagok" },
{ href: "/profil", label: "Profil" },
];
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
return (
<header className="site-header">
<Logo />
<NavLinks links={links} />
<div className="who">
<PackageBadge me={me} />
<Link href="/bevaltas" className="redeem-link">
Kód beváltása
</Link>
<span className="who-name">{me.user.display_name || me.user.email}</span>
<LogoutButton />
</div>
</header>
);
}