import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { SignTrio } from "@/components/ChartCard";
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
import { CompositeTables, CrossGrid, HouseOverlays, InterAspectList, NatureBar } from "@/components/SynastryTables";
import { SynastryLegend, SynastryWheel } from "@/components/SynastryWheel";
import { Tabs } from "@/components/Tabs";
import { ASPECTS, formatBirthDate } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server";
import { sideName, sideTimeKnown } from "@/lib/synastry";
import type { Analysis, ChartListItem, PublicConfig, Synastry, SynastrySide } from "@/lib/types";
export const metadata: Metadata = { title: "Összevetés" };
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const GRID_LEGEND = ["conjunction", "sextile", "square", "trine", "opposition"];
function Person({ side, which }: { side: SynastrySide; which: "p1" | "p2" }) {
const time = sideTimeKnown(side);
const birth = side.birth_data;
const name = sideName(side);
const body = (
<>
{name}
{birth && (
{formatBirthDate(birth.date)}
{time && birth.time ? `, ${birth.time.slice(0, 5)}` : ", ismeretlen időpont"}
)}
{side.highlights && (
)}
>
);
return side.owned ? (
{body}
) : (
{body}
);
}
/** One comparison of two charts: the double wheel, the numbers, the analysis and the tables. */
export default async function ComparisonPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const me = await requireMe(`/osszevetesek/${id}`);
if (!UUID.test(id)) notFound();
const [synastry, analyses, config] = await Promise.all([
backendGet(`/v1/synastries/${id}`),
backendGet<{ analyses: Analysis[] }>(`/v1/synastries/${id}/analyses`),
backendGet("/v1/config"),
]);
if (!synastry) notFound();
const list = analyses?.analyses ?? [];
const detailed = list.find((a) => a.status !== "failed") ?? list[0] ?? null;
const { chart1, chart2 } = synastry;
const name1 = sideName(chart1);
const name2 = sideName(chart2);
const time1 = sideTimeKnown(chart1);
const time2 = sideTimeKnown(chart2);
const result = synastry.synastry;
const unknown = [!time1 && name1, !time2 && name2].filter(Boolean);
return (
← Összevetések
{name1} és {name2}
Összevetés · két képlet egymásra vetítve
Számokban
{result.summary.aspect_count} fényszög köztetek
{unknown.length > 0 && (
{unknown.join(" és ")} születési ideje ismeretlen: az ő tengelyei és házai kimaradnak, a Hold helyzete
közelítő.
)}
),
},
{
id: "fenyszogek",
label: "Fényszögek",
content: (
{GRID_LEGEND.map((k) => (
-
{ASPECTS[k]?.glyph}
{" "}
{ASPECTS[k]?.hu}
))}
),
},
{ id: "hazak", label: "Házak", content: },
{ id: "kompozit", label: "Kompozit", content: },
{
id: "reszletek",
label: "Részletek",
content: ,
},
]}
/>
);
}