Header shows the user's package and what is left of it
CI / test (push) Successful in 51s
CI / build (push) Successful in 4m0s
CI / deploy (push) Skipped

- /v1/me: `package` = the running unlimited package, or the latest main
  package bought or given (top-ups do not count; an ended unlimited not)
- header badge: "Család · 11 elemzés", "Korlátlan · 2027. november 17-ig",
  "Páros · elfogyott"; links to the packages page, details in the tooltip

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-17 19:24:52 +00:00
co-authored by Claude Opus 5.5
parent 21640ffd9e
commit 742b88183b
6 changed files with 77 additions and 1 deletions
+9
View File
@@ -57,6 +57,14 @@ p { margin: 0; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 10px 12px; border-radius: 8px; min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--gold); background: rgba(217, 180, 106, 0.08); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.pkg-pill {
display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 999px;
border: 1px solid rgba(217, 180, 106, 0.5); color: var(--gold); text-decoration: none; font-size: 13px; white-space: nowrap;
}
.pkg-pill:hover { background: rgba(217, 180, 106, 0.08); color: var(--gold); }
.pkg-pill-detail { color: var(--muted); }
.pkg-pill-detail::before { content: "·"; margin-right: 6px; }
.pkg-pill-empty { border-color: var(--line-2); color: var(--ink-2); }
/* Layout */
.page { max-width: 960px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 24px; }
@@ -307,6 +315,7 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
h1 { font-size: 32px; }
.site-header { padding: 10px 16px; gap: 12px; }
.nav { order: 3; flex-basis: 100%; }
.who-name { display: none; }
.card { padding: 18px; }
.auth-aside { padding: 28px 20px; min-height: 0; }
.wheel { width: 60%; }
@@ -1,5 +1,6 @@
import Link from "next/link";
import { formatDate } from "@/lib/astro";
import type { Me } from "@/lib/types";
import { LogoutButton } from "./LogoutButton";
@@ -13,6 +14,41 @@ export function Logo() {
);
}
/** 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.unlimited_until) {
name = "Korlátlan";
detail = `${formatDate(me.unlimited_until).replace(/\.$/, "")}-ig`;
} else 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 = me.unlimited_until
? "Korlátlan elemzés és összevetés"
: `Képletelemzés: ${natal}, kapcsolati elemzés: ${synastry}`;
const empty = !me.unlimited_until && 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" },
@@ -27,7 +63,8 @@ export function SiteHeader({ me }: { me: Me }) {
<Logo />
<NavLinks links={links} />
<div className="who">
<span>{me.user.display_name || me.user.email}</span>
<PackageBadge me={me} />
<span className="who-name">{me.user.display_name || me.user.email}</span>
<LogoutButton />
</div>
</header>
+2
View File
@@ -21,6 +21,8 @@ export interface Me {
persons: PersonSlots;
/** The unlimited package runs until then (null: none). */
unlimited_until: string | null;
/** The running unlimited package, or the latest main package bought or given (null: none). */
package: { id: string; name: string; since: string } | null;
}
/** A package from the catalog (`GET /v1/packages`). */