2026-11-16 06:37:59 +00:00
|
|
|
|
import type { Metadata } from "next";
|
|
|
|
|
|
import Link from "next/link";
|
|
|
|
|
|
import { notFound } from "next/navigation";
|
|
|
|
|
|
|
|
|
|
|
|
import { BigThree, ChartTables } from "@/components/ChartTables";
|
2026-11-16 17:12:17 +00:00
|
|
|
|
import { ChartSummary } from "@/components/ChartSummary";
|
2026-11-16 06:37:59 +00:00
|
|
|
|
import { ChartWheel } from "@/components/ChartWheel";
|
|
|
|
|
|
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
|
|
|
|
|
import { backendGet, requireMe } from "@/lib/server";
|
2026-11-16 17:12:17 +00:00
|
|
|
|
import type { Analysis, Chart } from "@/lib/types";
|
2026-11-16 06:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
export const metadata: Metadata = { title: "Képlet" };
|
|
|
|
|
|
|
|
|
|
|
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
|
|
|
|
|
|
|
|
/** One saved chart: the wheel and the tables, read from the database (not recalculated). */
|
|
|
|
|
|
export default async function ChartPage({ params }: { params: Promise<{ id: string }> }) {
|
|
|
|
|
|
const { id } = await params;
|
|
|
|
|
|
await requireMe(`/kepletek/${id}`);
|
|
|
|
|
|
if (!UUID.test(id)) notFound();
|
2026-11-16 17:12:17 +00:00
|
|
|
|
const [chart, analyses] = await Promise.all([
|
|
|
|
|
|
backendGet<Chart>(`/v1/charts/${id}`),
|
|
|
|
|
|
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
|
|
|
|
|
|
]);
|
2026-11-16 06:37:59 +00:00
|
|
|
|
if (!chart) notFound();
|
2026-11-16 17:12:17 +00:00
|
|
|
|
const summary = analyses?.analyses.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
|
2026-11-16 06:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
const result = chart.chart;
|
|
|
|
|
|
const timeKnown = chart.highlights.time_known;
|
|
|
|
|
|
const place = result.location.place;
|
|
|
|
|
|
const country = place?.country_code ?? chart.birth_data.country;
|
|
|
|
|
|
const elements = result.summary?.elements;
|
|
|
|
|
|
const modalities = result.summary?.modalities;
|
|
|
|
|
|
const phase = result.moon_phase;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<main className="page" style={{ maxWidth: 1180 }}>
|
|
|
|
|
|
<div className="page-head">
|
|
|
|
|
|
<h1>{chart.is_primary ? "Születési képletem" : chart.label}</h1>
|
|
|
|
|
|
<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"}
|
|
|
|
|
|
{" · "}
|
|
|
|
|
|
{place?.name ?? chart.birth_data.place ?? "–"}
|
|
|
|
|
|
{country ? `, ${countryName(country)}` : ""}
|
|
|
|
|
|
{chart.is_primary && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{" · "}
|
|
|
|
|
|
<Link href="/profil#birth">adatok javítása</Link>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<section className="chart-layout" aria-label="Képletrajz">
|
|
|
|
|
|
<div className="card chart-wheel-card">
|
|
|
|
|
|
<ChartWheel chart={result} timeKnown={timeKnown} />
|
|
|
|
|
|
<p className="hint wheel-legend">
|
|
|
|
|
|
<span className="legend-line legend-harmonic" aria-hidden="true" /> harmonikus (trigon, szextil)
|
|
|
|
|
|
<span className="legend-line legend-tense" aria-hidden="true" /> feszült (kvadrát, szembenállás)
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="field" style={{ gap: 16 }}>
|
2026-11-16 17:12:17 +00:00
|
|
|
|
<ChartSummary chartId={chart.id} initial={summary} />
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<BigThree chart={chart} />
|
|
|
|
|
|
{(elements || modalities || phase) && (
|
|
|
|
|
|
<div className="card" style={{ gap: 12 }}>
|
|
|
|
|
|
<dl className="facts">
|
|
|
|
|
|
{elements && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<dt>Elemek</dt>
|
|
|
|
|
|
<dd>
|
|
|
|
|
|
{Object.entries(elements)
|
|
|
|
|
|
.map(([k, v]) => `${ELEMENTS[k] ?? k} ${v.count}`)
|
|
|
|
|
|
.join(" · ")}
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{modalities && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<dt>Minőségek</dt>
|
|
|
|
|
|
<dd>
|
|
|
|
|
|
{Object.entries(modalities)
|
|
|
|
|
|
.map(([k, v]) => `${MODALITIES[k] ?? k} ${v.count}`)
|
|
|
|
|
|
.join(" · ")}
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{phase && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<dt>Holdfázis</dt>
|
|
|
|
|
|
<dd>
|
|
|
|
|
|
{MOON_PHASES[phase.phase] ?? phase.phase}, {Math.round(phase.illumination * 100)}%
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</dl>
|
|
|
|
|
|
{elements && (
|
|
|
|
|
|
<p className="hint">
|
|
|
|
|
|
Az elemek és minőségek a tíz bolygóból számolva:{" "}
|
|
|
|
|
|
{Object.entries(elements)
|
|
|
|
|
|
.filter(([, v]) => v.count > 0)
|
|
|
|
|
|
.map(([k, v]) => `${ELEMENTS[k] ?? k}: ${v.points.map(pointName).join(", ")}`)
|
|
|
|
|
|
.join("; ")}
|
|
|
|
|
|
.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section className="card" aria-labelledby="positions">
|
|
|
|
|
|
<h2 id="positions">Pozíciók</h2>
|
|
|
|
|
|
<ChartTables chart={chart} />
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</main>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|