Chart page with a drawn wheel; reuse saved charts for identical birth data
- New /kepletek/[id] page: chart wheel (SVG), big three, elements, modalities, moon phase, positions and an aspects table. /keplet opens the user's own chart; the home page goes there after login. - The profile only shows the birth data, with a link to the chart. - Saving the same birth data again returns the stored chart (200) instead of calculating a new one. - Charts without a birth time (angles null) render without houses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -13,7 +13,7 @@ export const metadata: Metadata = { title: "Belépés" };
|
||||
/** Only local paths, so the login cannot redirect to another site. */
|
||||
function safeTarget(value: string | string[] | undefined): string {
|
||||
const v = Array.isArray(value) ? value[0] : value;
|
||||
return v && v.startsWith("/") && !v.startsWith("//") ? v : "/profil";
|
||||
return v && v.startsWith("/") && !v.startsWith("//") ? v : "/";
|
||||
}
|
||||
|
||||
async function loadConfig(): Promise<PublicConfig | null> {
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
--gold-ink: #141a2c;
|
||||
--danger: #f2a0a0;
|
||||
--ok: #9fd8b0;
|
||||
--harmonic: #7fb0e0;
|
||||
--tense: #e38b8b;
|
||||
--radius: 10px;
|
||||
--font-display: var(--font-cormorant), "Cormorant Garamond", Georgia, serif;
|
||||
--font-body: var(--font-inter), Inter, system-ui, sans-serif;
|
||||
@@ -145,6 +147,51 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.tagline { font-family: var(--font-display); font-size: 36px; font-weight: 600; line-height: 1.1; }
|
||||
.gsi-slot { min-height: 44px; display: flex; justify-content: center; }
|
||||
|
||||
/* Chart page */
|
||||
.chart-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
|
||||
.chart-wheel-card { padding: 16px; gap: 10px; }
|
||||
.chart-wheel { width: 100%; height: auto; display: block; max-width: 680px; margin: 0 auto; }
|
||||
.chart-layout .big3 { grid-template-columns: 1fr; }
|
||||
.wheel-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; justify-content: center; }
|
||||
.legend-line { display: inline-block; width: 22px; height: 2px; border-radius: 1px; margin-left: 6px; }
|
||||
.legend-harmonic { background: var(--harmonic); }
|
||||
.legend-tense { background: var(--tense); }
|
||||
.aspect-tag { white-space: nowrap; }
|
||||
.aspect-harmonic { color: var(--harmonic); }
|
||||
.aspect-tense { color: var(--tense); }
|
||||
.aspect-neutral { color: var(--gold); }
|
||||
|
||||
.w-ring { fill: none; stroke: var(--line-2); stroke-width: 1.2; }
|
||||
.w-faint { stroke: var(--line); }
|
||||
.w-inner { fill: var(--panel-2); }
|
||||
.w-sign { stroke: var(--line-2); stroke-width: 1; }
|
||||
.w-fire { fill: rgba(227, 139, 106, 0.09); }
|
||||
.w-earth { fill: rgba(159, 216, 176, 0.07); }
|
||||
.w-air { fill: rgba(217, 180, 106, 0.08); }
|
||||
.w-water { fill: rgba(127, 176, 224, 0.09); }
|
||||
.w-sign-glyph { fill: var(--gold); font-family: var(--font-symbols); font-size: 22px; }
|
||||
.w-tick { stroke: var(--line-2); stroke-width: 1; }
|
||||
.w-cusp { stroke: var(--line-2); stroke-width: 1; }
|
||||
.w-axis { stroke: var(--gold); stroke-width: 1.8; }
|
||||
.w-axis-label { fill: var(--gold); font: 600 14px var(--font-body); letter-spacing: 0.5px; }
|
||||
.w-house-num { fill: var(--muted); font: 500 12px var(--font-body); }
|
||||
.w-aspect { stroke-linecap: round; }
|
||||
.w-harmonic { stroke: var(--harmonic); }
|
||||
.w-tense { stroke: var(--tense); }
|
||||
.w-neutral { stroke: var(--gold); }
|
||||
.w-point-tick { stroke: var(--ink); stroke-width: 1.6; }
|
||||
.w-leader { stroke: var(--muted); stroke-width: 0.7; stroke-opacity: 0.6; }
|
||||
.w-point-glyph { fill: var(--ink); font-family: var(--font-symbols); font-size: 22px; }
|
||||
.w-point-deg { fill: var(--muted); font: 500 10.5px var(--font-body); }
|
||||
.w-end { fill: var(--ink-2); }
|
||||
.w-point-glyph, .w-point-deg, .w-house-num, .w-axis-label { paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
|
||||
.w-point:hover .w-point-glyph { fill: var(--gold); }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.chart-layout { grid-template-columns: 1fr; }
|
||||
.chart-layout .big3 { grid-template-columns: repeat(3, 1fr); }
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
h1 { font-size: 32px; }
|
||||
.site-header { padding: 10px 16px; gap: 12px; }
|
||||
@@ -152,7 +199,8 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.card { padding: 18px; }
|
||||
.auth-aside { padding: 28px 20px; min-height: 0; }
|
||||
.wheel { width: 60%; }
|
||||
.big3 { grid-template-columns: 1fr; }
|
||||
.big3, .chart-layout .big3 { grid-template-columns: 1fr; }
|
||||
.chart-wheel-card { padding: 8px; }
|
||||
}
|
||||
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { requireMe } from "@/lib/server";
|
||||
|
||||
// The user's own chart; without birth data the profile asks for it.
|
||||
export default async function MyChart() {
|
||||
const me = await requireMe("/keplet");
|
||||
redirect(me.primary_chart_id ? `/kepletek/${me.primary_chart_id}` : "/profil#birth");
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { BigThree, ChartTables } from "@/components/ChartTables";
|
||||
import { ChartWheel } from "@/components/ChartWheel";
|
||||
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Chart } from "@/lib/types";
|
||||
|
||||
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();
|
||||
const chart = await backendGet<Chart>(`/v1/charts/${id}`);
|
||||
if (!chart) notFound();
|
||||
|
||||
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 }}>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,9 @@ import { redirect } from "next/navigation";
|
||||
|
||||
import { getMe } from "@/lib/server";
|
||||
|
||||
// No home page yet: logged-in users go to their profile, others to login.
|
||||
// No home page yet: logged-in users go to their chart (or to the profile to enter
|
||||
// their birth data), others to login.
|
||||
export default async function Home() {
|
||||
redirect((await getMe()) ? "/profil" : "/belepes");
|
||||
const me = await getMe();
|
||||
redirect(!me ? "/belepes" : me.primary_chart_id ? "/keplet" : "/profil");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { countryName, formatBirthDate } from "@/lib/astro";
|
||||
@@ -17,8 +19,9 @@ export interface SavedBirth {
|
||||
dst: boolean;
|
||||
}
|
||||
|
||||
/** Shows the saved birth data (and the chart tables), or the form to enter or correct it. */
|
||||
export function BirthEditor({ chart, children }: { chart: SavedBirth | null; children: React.ReactNode }) {
|
||||
/** Shows the saved birth data, or the form to enter or correct it. Saving opens the chart page. */
|
||||
export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; chartId: string | null }) {
|
||||
const router = useRouter();
|
||||
const [editing, setEditing] = useState(chart === null);
|
||||
|
||||
if (editing || !chart) {
|
||||
@@ -38,7 +41,7 @@ export function BirthEditor({ chart, children }: { chart: SavedBirth | null; chi
|
||||
<BirthForm
|
||||
initial={chart ? { ...chart.birth, placeName: chart.placeName, region: chart.region } : null}
|
||||
onCancel={chart ? () => setEditing(false) : undefined}
|
||||
onSaved={() => setEditing(false)}
|
||||
onSaved={(id) => router.push(`/kepletek/${id}`)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -47,7 +50,7 @@ export function BirthEditor({ chart, children }: { chart: SavedBirth | null; chi
|
||||
const { birth } = chart;
|
||||
const country = chart.countryCode ?? birth.country;
|
||||
return (
|
||||
<div className="field" style={{ gap: 24 }}>
|
||||
<div className="field">
|
||||
<div className="card-head" style={{ alignItems: "flex-start" }}>
|
||||
<dl className="facts">
|
||||
<dt>Dátum</dt>
|
||||
@@ -73,11 +76,17 @@ export function BirthEditor({ chart, children }: { chart: SavedBirth | null; chi
|
||||
{country && <span className="muted">, {countryName(country)}</span>}
|
||||
</dd>
|
||||
</dl>
|
||||
<button type="button" className="btn" onClick={() => setEditing(true)}>
|
||||
Adatok javítása
|
||||
</button>
|
||||
<div className="row">
|
||||
{chartId && (
|
||||
<Link href={`/kepletek/${chartId}`} className="btn btn-primary">
|
||||
Képlet megnyitása
|
||||
</Link>
|
||||
)}
|
||||
<button type="button" className="btn" onClick={() => setEditing(true)}>
|
||||
Adatok javítása
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
|
||||
import { ApiError, api, errorText } from "@/lib/api";
|
||||
@@ -24,9 +23,8 @@ export function BirthForm({
|
||||
}: {
|
||||
initial: Initial;
|
||||
onCancel?: () => void;
|
||||
onSaved: () => void;
|
||||
onSaved: (chartId: string) => void;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [date, setDate] = useState(initial?.date ?? "");
|
||||
const [time, setTime] = useState(initial?.time?.slice(0, 5) ?? "");
|
||||
const [timeUnknown, setTimeUnknown] = useState(initial ? !initial.time : false);
|
||||
@@ -56,7 +54,7 @@ export function BirthForm({
|
||||
if (!place) return setError("Válaszd ki a születési helyet a listából.");
|
||||
setBusy(true);
|
||||
try {
|
||||
await api("/charts", {
|
||||
const saved = await api<{ id: string }>("/charts", {
|
||||
body: {
|
||||
label: "Saját képlet",
|
||||
is_primary: true,
|
||||
@@ -69,8 +67,7 @@ export function BirthForm({
|
||||
},
|
||||
},
|
||||
});
|
||||
onSaved();
|
||||
router.refresh();
|
||||
onSaved(saved.id);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.code === "ambiguous_local_time") {
|
||||
setAmbiguous(true);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
import { ChartTables } from "@/components/ChartTables";
|
||||
import { ROLE_LABELS, formatDate } from "@/lib/astro";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Chart } from "@/lib/types";
|
||||
@@ -21,7 +20,7 @@ export default async function ProfilePage() {
|
||||
<main className="page">
|
||||
<div className="page-head">
|
||||
<h1>Profil</h1>
|
||||
<p className="muted">A fiókod adatai és a saját születési képleted.</p>
|
||||
<p className="muted">A fiókod és a születési adataid.</p>
|
||||
</div>
|
||||
|
||||
<section className="card" aria-labelledby="account">
|
||||
@@ -71,9 +70,8 @@ export default async function ProfilePage() {
|
||||
}
|
||||
: null
|
||||
}
|
||||
>
|
||||
{chart && <ChartTables chart={chart} />}
|
||||
</BirthEditor>
|
||||
chartId={chart?.id ?? null}
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user