Own chart back on the Képletem menu; persons get their own menu, page and a tile
CI / test (push) Failing after 41s
CI / build (push) Skipped
CI / deploy (push) Skipped

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 11:20:26 +00:00
co-authored by Claude Opus 5.5
parent fef1605848
commit 0791998c13
9 changed files with 114 additions and 92 deletions
@@ -19,7 +19,7 @@ export function EditPerson({
<BirthForm
initial={initial}
person={{ chartId: id, name }}
onCancel={() => router.push("/kepletek")}
onCancel={() => router.push("/szemelyek")}
onSaved={() => {
router.push(`/kepletek/${id}`);
router.refresh();
@@ -1,4 +1,5 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
@@ -29,6 +30,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
]);
const charts = chartList?.charts ?? [];
const persons = charts.filter((c) => c.kind === "person");
if (!chart) notFound();
const list = analyses?.analyses ?? [];
const summary = list.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
@@ -50,7 +52,7 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
title={chart.is_primary ? "Születési képletem" : chart.label}
currentId={chart.id}
own={charts.find((c) => c.is_primary) ?? null}
persons={charts.filter((c) => c.kind === "person")}
persons={persons}
canAdd={me.persons.left !== 0}
/>
<p className="muted">
@@ -114,6 +116,22 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
)}
</div>
)}
{chart.is_primary && (
<Link href="/szemelyek" className="card persons-tile">
<span className="eyebrow">Személyek</span>
<strong>
{persons.length > 0 ? `${persons.length} felvett személy` : "Társad, családod képlete"}
</strong>
<span className="muted">
{persons.length > 0
? persons.slice(0, 3).map((p) => p.label).join(", ") + (persons.length > 3 ? "…" : "")
: "Vedd fel őket, és nézd meg az ő képletüket és elemzésüket is."}
</span>
<span className="persons-tile-arrow" aria-hidden="true">
→
</span>
</Link>
)}
</div>
</section>
+4 -85
View File
@@ -1,87 +1,6 @@
import type { Metadata } from "next";
import Link from "next/link";
import { redirect } from "next/navigation";
import { ChartCard } from "@/components/ChartCard";
import { PersonActions } from "@/components/PersonActions";
import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { ChartListItem, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Képletek" };
/** The user's own chart and the persons they added, with room for a new one. */
export default async function ChartsPage() {
const me = await requireMe("/kepletek");
const [list, config] = await Promise.all([
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
backendGet<PublicConfig>("/v1/config"),
]);
const charts = list?.charts ?? [];
const own = charts.find((c) => c.is_primary);
const persons = charts.filter((c) => c.kind === "person");
const isAdmin = me.user.roles.includes("admin");
const slots = me.persons;
const full = slots.left === 0;
const now = Date.now();
return (
<main className="page" style={{ maxWidth: 1080 }}>
<div className="page-head">
<h1>Képletek</h1>
<p className="muted">A saját képleted és azoké, akiket felvettél: mindegyikhez kérhetsz részletes elemzést.</p>
</div>
<div className="chart-cards">
{own ? (
<ChartCard chart={own} title="Én">
<span className="chart-card-tag">Saját képletem</span>
</ChartCard>
) : (
<Link href="/profil#birth" className="chart-card chart-card-new">
<strong className="chart-card-name">Én</strong>
<span className="muted">Add meg a születési adataidat a profilodban.</span>
</Link>
)}
{persons.map((p) => (
<ChartCard key={p.id} chart={p} title={p.label}>
<PersonActions
id={p.id}
name={p.label}
editable={isAdmin || (p.editable_until !== null && Date.parse(p.editable_until) > now)}
/>
</ChartCard>
))}
{!full && (
<Link href="/kepletek/uj" className="chart-card chart-card-new">
<span className="chart-card-plus" aria-hidden="true">
+
</span>
<strong className="chart-card-name">Új személy</strong>
<span className="muted">
{slots.unlimited ? "Korlátlan számú személy" : `Még ${slots.left} személyt vehetsz fel`}
</span>
</Link>
)}
</div>
{!slots.unlimited && (
<section className="card" aria-labelledby="slots-title">
<div className="card-head">
<h2 id="slots-title">Személyek</h2>
<span className="badge">
{slots.used} / {slots.limit} hely
</span>
</div>
<p className="muted">
{full
? "Elfogytak a helyeid. Újabb személyhez válassz csomagot."
: "A felvett személyek képletét és elemzéseit itt éred el. Egy törölt személy helye nem szabadul fel."}
</p>
<PersonPacks packSize={config?.person_pack_size ?? 5} canPay={config?.mock_payments ?? false} />
</section>
)}
</main>
);
// The persons list moved to /szemelyek.
export default function ChartsIndex() {
redirect("/szemelyek");
}
@@ -1,17 +0,0 @@
"use client";
import { useRouter } from "next/navigation";
import { BirthForm } from "@/app/profil/BirthForm";
export function NewPerson() {
const router = useRouter();
return (
<BirthForm
initial={null}
person={{}}
onCancel={() => router.push("/kepletek")}
onSaved={(id) => router.push(`/kepletek/${id}`)}
/>
);
}
@@ -1,40 +0,0 @@
import type { Metadata } from "next";
import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { PublicConfig } from "@/lib/types";
import { NewPerson } from "./NewPerson";
export const metadata: Metadata = { title: "Új személy" };
export default async function NewPersonPage() {
const me = await requireMe("/kepletek/uj");
const config = await backendGet<PublicConfig>("/v1/config");
const slots = me.persons;
return (
<main className="page">
<div className="page-head">
<h1>Új személy</h1>
<p className="muted">
Társad, családtagod, barátod: a születési adataiból elkészül a képlete és egy rövid összefoglaló.
{!slots.unlimited && slots.left !== null && slots.left > 0 && ` Még ${slots.left} személyt vehetsz fel.`}
</p>
</div>
<section className="card" aria-label="Születési adatok">
{slots.left === 0 ? (
<>
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot.</p>
<PersonPacks packSize={config?.person_pack_size ?? 5} canPay={config?.mock_payments ?? false} />
</>
) : (
<>
<NewPerson />
<p className="hint">Az adatokat a felvételt követő egy órán belül még javíthatod, utána nem módosíthatók.</p>
</>
)}
</section>
</main>
);
}