Persons: other people's charts with package slots, list page, switcher
CI / test (push) Failing after 43s
CI / build (push) Skipped
CI / deploy (push) Skipped

- charts.kind own/person; a new person uses a 'person' unit (not refunded
  on delete); person packages and an unlimited entitlement; admins unlimited
- a person's birth data can be corrected within an hour (admins any time)
- /kepletek list with tiles, /kepletek/uj, correction page, mock person
  packages, chart page title switches between charts keeping the tab

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:03:55 +00:00
co-authored by Claude Opus 5.5
parent 50875c0006
commit fef1605848
28 changed files with 1008 additions and 54 deletions
@@ -0,0 +1,29 @@
"use client";
import { useRouter } from "next/navigation";
import { BirthForm } from "@/app/profil/BirthForm";
import type { BirthData } from "@/lib/types";
export function EditPerson({
id,
name,
initial,
}: {
id: string;
name: string;
initial: BirthData & { placeName: string | null; region: string | null };
}) {
const router = useRouter();
return (
<BirthForm
initial={initial}
person={{ chartId: id, name }}
onCancel={() => router.push("/kepletek")}
onSaved={() => {
router.push(`/kepletek/${id}`);
router.refresh();
}}
/>
);
}
@@ -0,0 +1,54 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { backendGet, requireMe } from "@/lib/server";
import type { Chart } from "@/lib/types";
import { EditPerson } from "./EditPerson";
export const metadata: Metadata = { title: "Adatok javítása" };
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
/** Correcting a person's birth data (within an hour of adding them; admins any time). */
export default async function EditPersonPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const me = await requireMe(`/kepletek/${id}/javitas`);
if (!UUID.test(id)) notFound();
const chart = await backendGet<Chart>(`/v1/charts/${id}`);
if (!chart || chart.kind !== "person") notFound();
const editable =
me.user.roles.includes("admin") || (chart.editable_until !== null && Date.parse(chart.editable_until) > Date.now());
return (
<main className="page">
<div className="page-head">
<h1>{chart.label} adatai</h1>
<p className="muted">
A javítás után újraszámoljuk a képletet és a rövid összefoglalót.
</p>
</div>
<section className="card" aria-label="Születési adatok">
{editable ? (
<EditPerson
id={id}
name={chart.label}
initial={{
...chart.birth_data,
placeName: chart.chart.location.place?.name ?? null,
region: chart.chart.location.place?.region ?? null,
}}
/>
) : (
<>
<p className="muted">A személy születési adatai csak a felvételt követő egy órán belül javíthatók.</p>
<Link href={`/kepletek/${id}`} className="btn" style={{ alignSelf: "flex-start" }}>
Vissza a képlethez
</Link>
</>
)}
</section>
</main>
);
}
@@ -3,12 +3,13 @@ import { notFound } from "next/navigation";
import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
import { ChartSummary } from "@/components/ChartSummary";
import { ChartSwitcher } from "@/components/ChartSwitcher";
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
import { Tabs } from "@/components/Tabs";
import { ASPECTS, ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server";
import type { Analysis, Chart, PublicConfig } from "@/lib/types";
import type { Analysis, Chart, ChartListItem, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Képlet" };
@@ -21,11 +22,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
const { id } = await params;
const me = await requireMe(`/kepletek/${id}`);
if (!UUID.test(id)) notFound();
const [chart, analyses, config] = await Promise.all([
const [chart, analyses, config, chartList] = await Promise.all([
backendGet<Chart>(`/v1/charts/${id}`),
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
backendGet<PublicConfig>("/v1/config"),
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
]);
const charts = chartList?.charts ?? [];
if (!chart) notFound();
const list = analyses?.analyses ?? [];
const summary = list.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
@@ -43,7 +46,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
return (
<main className="page" style={{ maxWidth: 1180 }}>
<div className="page-head">
<h1>{chart.is_primary ? "Születési képletem" : chart.label}</h1>
<ChartSwitcher
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")}
canAdd={me.persons.left !== 0}
/>
<p className="muted">
{formatBirthDate(chart.birth_data.date)}
{timeKnown ? `, ${result.time.local.slice(11, 16)} (UTC${result.time.utc_offset}${result.time.dst ? ", nyári idő" : ""})` : ", ismeretlen időpont"}
@@ -0,0 +1,87 @@
import type { Metadata } from "next";
import Link from "next/link";
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>
);
}
@@ -0,0 +1,17 @@
"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}`)}
/>
);
}
@@ -0,0 +1,40 @@
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>
);
}