Detailed analysis button, loading wheel, birth data change limits
CI / test (push) Successful in 41s
CI / build (push) Successful in 4m11s
CI / deploy (push) Skipped

Backend:
- own birth data: three corrections within an hour of the first save,
  then one change per 24 hours (birth_data_changes); 429
  birth_data_change_limit with the user-facing message; /v1/me
  birth_change shows the notice; admins are not limited
- admins get detailed analyses free (no unit spent)
- POST /v1/payments/mock (MOCK_PAYMENTS): stand-in payment that adds a
  unit, until Stripe is connected; on in the compose files for now

Frontend:
- detailed analysis offer: admin starts it free, users with units
  confirm, others go through the (stand-in) payment step
- turning wheel with elapsed time while the summary or the analysis is
  being written
- no "adatok javítása" on the chart page (only in the profile), limit
  notice there; wheel hover highlighting removed

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 06:45:33 +00:00
co-authored by Claude Opus 5.5
parent 85337f2c79
commit e5cfbd6cdd
23 changed files with 544 additions and 110 deletions
+15 -3
View File
@@ -192,6 +192,21 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.skeleton span:last-child { width: 60%; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .skeleton span { animation: none; } }
/* Loading while the LLM writes */
.loading { display: flex; align-items: center; gap: 24px; padding: 8px 0; }
.loading-wheel { width: 120px; height: 120px; flex: none; animation: spin 24s linear infinite; }
.loading-compact .loading-wheel { width: 64px; height: 64px; }
.loading-text { display: flex; flex-direction: column; gap: 6px; }
.loading-text strong { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.loading-text .muted { animation: pulse 2.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-wheel, .loading-text .muted { animation: none; } }
@media (max-width: 640px) { .loading { flex-direction: column; text-align: center; } }
/* Payment step */
.pay-box { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
.pay-line { display: flex; justify-content: space-between; gap: 12px; }
.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; }
@@ -224,13 +239,10 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.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-aspect { transition: stroke-opacity 0.15s; }
.w-asp-trine { stroke: var(--harmonic); }
.w-asp-sextile { stroke: var(--harmonic); stroke-dasharray: 5 4; }
.w-asp-square { stroke: var(--square); }
.w-asp-opposition { stroke: var(--tense); }
.w-point { outline: none; cursor: default; }
.w-point:focus-visible .w-point-glyph { fill: 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; }
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { BigThree, ChartTables } from "@/components/ChartTables";
@@ -8,7 +7,7 @@ import { DetailedAnalysis } from "@/components/DetailedAnalysis";
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server";
import type { Analysis, Chart } from "@/lib/types";
import type { Analysis, Chart, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Képlet" };
@@ -19,9 +18,10 @@ 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] = await Promise.all([
const [chart, analyses, config] = await Promise.all([
backendGet<Chart>(`/v1/charts/${id}`),
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
backendGet<PublicConfig>("/v1/config"),
]);
if (!chart) notFound();
const list = analyses?.analyses ?? [];
@@ -47,12 +47,6 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
{" · "}
{place?.name ?? chart.birth_data.place ?? "–"}
{country ? `, ${countryName(country)}` : ""}
{chart.is_primary && (
<>
{" · "}
<Link href="/profil#birth">adatok javítása</Link>
</>
)}
</p>
</div>
@@ -111,7 +105,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
</div>
</section>
<DetailedAnalysis chartId={chart.id} initial={detailed} left={me.analyses_left.natal} />
<DetailedAnalysis
chartId={chart.id}
initial={detailed}
left={me.analyses_left.natal}
isAdmin={me.user.roles.includes("admin")}
canPay={config?.mock_payments ?? false}
/>
<section className="card" aria-labelledby="positions">
<h2 id="positions">Pozíciók</h2>
@@ -19,8 +19,19 @@ export interface SavedBirth {
dst: boolean;
}
/** 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 }) {
/**
* Shows the saved birth data, or the form to enter or correct it. Saving opens
* the chart page. `notice`: the backend's text about the change limit, if any.
*/
export function BirthEditor({
chart,
chartId,
notice,
}: {
chart: SavedBirth | null;
chartId: string | null;
notice: string | null;
}) {
const router = useRouter();
const [editing, setEditing] = useState(chart === null);
@@ -38,6 +49,7 @@ export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; char
időszámítást) a születési hely alapján magunk határozzuk meg.
</p>
)}
{chart && notice && <p className="msg">{notice}</p>}
<BirthForm
initial={chart ? { ...chart.birth, placeName: chart.placeName, region: chart.region } : null}
onCancel={chart ? () => setEditing(false) : undefined}
@@ -87,6 +99,7 @@ export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; char
</button>
</div>
</div>
{notice && <p className="hint">{notice}</p>}
</div>
);
}
@@ -73,6 +73,7 @@ export default async function ProfilePage() {
: null
}
chartId={chart?.id ?? null}
notice={me.birth_change.notice}
/>
</section>
</main>
@@ -0,0 +1,30 @@
"use client";
import { useEffect, useState } from "react";
import { ZodiacWheel } from "./ZodiacWheel";
/** Slowly turning wheel with the elapsed time, while the LLM writes. */
export function AnalysisLoading({ title, text, compact = false }: { title?: string; text: string; compact?: boolean }) {
const [seconds, setSeconds] = useState(0);
useEffect(() => {
const t = setInterval(() => setSeconds((s) => s + 1), 1000);
return () => clearInterval(t);
}, []);
const elapsed = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
return (
<div className={compact ? "loading loading-compact" : "loading"}>
<ZodiacWheel className="loading-wheel" />
<div className="loading-text">
{title && <strong>{title}</strong>}
<p className="muted" role="status">
{text}
</p>
<p className="hint" aria-hidden="true">
{elapsed}
</p>
</div>
</div>
);
}
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
import { api } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { Rich } from "./Rich";
const POLL_MS = 3000;
@@ -62,17 +63,12 @@ export function ChartSummary({ chartId, initial }: { chartId: string; initial: A
<h2 id="summary-title" className="sr-only">
Rövid összefoglaló
</h2>
<p className="muted" role="status">
{gaveUp || summary?.status === "failed"
? "Az összefoglaló most nem készült el. Töltsd újra az oldalt egy kicsit később."
: "Az összefoglalód készül, ez néhány másodperc…"}
</p>
{!gaveUp && summary?.status !== "failed" && (
<div className="skeleton" aria-hidden="true">
<span />
<span />
<span />
</div>
{gaveUp || summary?.status === "failed" ? (
<p className="muted" role="status">
Az összefoglaló most nem készült el. Töltsd újra az oldalt egy kicsit később.
</p>
) : (
<AnalysisLoading compact text="Az összefoglalód készül, ez néhány másodperc…" />
)}
</>
)}
@@ -116,13 +116,6 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
.filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends.has(a.point1) && ends.has(a.point2))
.map((a) => ({ ...a, strength: a.max_orb > 0 ? 1 - Math.min(a.orb / a.max_orb, 1) : 0.5 }))
.sort((x, y) => x.strength - y.strength);
// Hovering or focusing a point shows only its aspects.
const highlight = [...ends.keys()]
.map((id) => {
const on = `.chart-wheel:has(.p-${id}:hover, .p-${id}:focus-visible)`;
return `${on} .w-aspect:not(.a-${id}){stroke-opacity:0.06}${on} .w-aspect.a-${id}{stroke-opacity:1}`;
})
.join("\n");
const description = points
.map((p) => `${pointName(p.id)} ${signName(p.sign)} ${dms(p.degree_in_sign_dms)}`)
@@ -192,7 +185,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
key={key}
x={f(x)}
y={f(y)}
className={`w-axis-label p-${key}`}
className="w-axis-label"
dominantBaseline="central"
textAnchor="middle"
>
@@ -207,7 +200,6 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
)}
{/* Aspects */}
<style>{highlight}</style>
<circle cx={C} cy={C} r={R_INNER} className="w-ring w-inner" />
{aspects.map((a) => {
const [x1, y1] = xy(ends.get(a.point1)!, R_INNER, start);
@@ -220,7 +212,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
y1={f(y1)}
x2={f(x2)}
y2={f(y2)}
className={`w-aspect w-asp-${a.aspect} a-${a.point1} a-${a.point2}`}
className={`w-aspect w-asp-${a.aspect}`}
strokeOpacity={(0.2 + 0.8 * s * s).toFixed(2)}
strokeWidth={(0.6 + 1.9 * s).toFixed(2)}
>
@@ -242,7 +234,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
const [ex, ey] = xy(placed[i], R_INNER, start);
const deg = Number.parseInt(p.degree_in_sign_dms, 10);
return (
<g key={p.id} className={`w-point p-${p.id}`} tabIndex={0}>
<g key={p.id} className="w-point">
<title>
{pointName(p.id)}: {dms(p.degree_in_sign_dms)} {signName(p.sign)}
{p.retrograde ? ", retrográd" : ""}
@@ -282,7 +274,7 @@ export function WheelLegend() {
</span>
))}
</p>
<p>Vastagabb vonal: szorosabb fényszög. Egy bolygóra mutatva csak az ő fényszögei látszanak.</p>
<p>Vastagabb vonal: szorosabb fényszög.</p>
<p>A körön a bolygók, az ASC és az MC főfényszögei vannak; az összes fényszög a táblázatban.</p>
</div>
);
@@ -6,27 +6,35 @@ import { useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { AnalysisView } from "./AnalysisView";
const POLL_MS = 5000;
const MAX_POLLS = 120; // 10 minutes
type Step = "offer" | "confirm" | "pay";
/**
* The paid detailed analysis of a chart: offer (with the units left),
* confirmation, progress while the worker writes it, and the finished text.
* The detailed analysis of a chart. A saved one is shown at once; otherwise
* the offer: admins start it free, users with units confirm, others pay
* (a stand-in payment for now). While the worker writes it, a loading wheel.
*/
export function DetailedAnalysis({
chartId,
initial,
left,
isAdmin,
canPay,
}: {
chartId: string;
initial: Analysis | null;
left: number;
isAdmin: boolean;
/** The stand-in payment is on (MOCK_PAYMENTS). */
canPay: boolean;
}) {
const [analysis, setAnalysis] = useState<Analysis | null>(initial);
const [remaining, setRemaining] = useState(left);
const [confirming, setConfirming] = useState(false);
const [step, setStep] = useState<Step>("offer");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const waiting = analysis?.status === "pending" || analysis?.status === "running";
@@ -54,14 +62,13 @@ export function DetailedAnalysis({
};
}, [waiting, analysis]);
async function request() {
async function start(pay: boolean) {
setBusy(true);
setError(null);
try {
const next = await api<Analysis>(`/charts/${chartId}/analyses`, { method: "POST" });
setAnalysis(next);
if (next.credits_charged > 0) setRemaining((n) => n - 1);
setConfirming(false);
if (pay) await api("/payments/mock", { body: { unit: "natal" } });
setAnalysis(await api<Analysis>(`/charts/${chartId}/analyses`, { method: "POST" }));
setStep("offer");
} catch (e) {
setError(errorText(e));
} finally {
@@ -78,67 +85,97 @@ export function DetailedAnalysis({
);
}
if (waiting) {
return (
<section className="card analysis-card" aria-label="Részletes elemzés" aria-busy="true">
<span className="eyebrow">Részletes elemzés</span>
<AnalysisLoading
title="Készül az elemzésed"
text="Most íródik a hat fejezet a képleted alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár."
/>
</section>
);
}
return (
<section className="card analysis-card" aria-labelledby="detailed-title" aria-busy={waiting}>
<section className="card analysis-card" aria-labelledby="detailed-title">
<span className="eyebrow">Részletes elemzés</span>
{waiting ? (
<>
<h2 id="detailed-title">Készül az elemzésed</h2>
<p className="muted" role="status">
A mesterséges intelligencia most írja meg a hat fejezetet a képleted alapján. Ez általában 1–2 perc; nyugodtan
elhagyhatod az oldalt, az elemzés elkészül és itt vár.
</p>
<div className="skeleton" aria-hidden="true">
<span />
<span />
<span />
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
<p className="muted">
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési út.
A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.
</p>
{analysis?.status === "failed" && (
<p className="msg msg-error" role="alert">
Az előző kérés nem sikerült{isAdmin ? "" : ", az elemzést visszaadtuk a keretedbe"}. Próbáld újra.
</p>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
{isAdmin ? (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
{busy ? "Indítás…" : "Részletes elemzés készítése"}
</button>
<span className="hint">Adminként ingyenes.</span>
</div>
) : left > 0 ? (
step === "confirm" ? (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
{busy ? "Indítás…" : "Igen, kérem az elemzést"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
Mégse
</button>
<span className="hint">Ez felhasznál 1-et a {left} képletelemzésedből.</span>
</div>
</>
) : (
<>
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
<p className="muted">
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési
út. A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.
</p>
{analysis?.status === "failed" && (
<p className="msg msg-error" role="alert">
Az előző kérés nem sikerült, az elemzést visszaadtuk a keretedbe. Próbáld újra.
</p>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
{remaining > 0 ? (
confirming ? (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={request} disabled={busy}>
{busy ? "Indítás…" : "Igen, kérem az elemzést"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setConfirming(false)} disabled={busy}>
Mégse
</button>
<span className="hint">Ez felhasznál 1-et a {remaining} képletelemzésedből.</span>
</div>
) : (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => setConfirming(true)}>
Részletes elemzés kérése
</button>
<span className="hint">Még {remaining} képletelemzésed van.</span>
</div>
)
) : (
<div className="form-actions">
<Link href="/pelda" className="btn">
Példa megtekintése
</Link>
<span className="hint">A részletes elemzés fizetős; a csomagok hamarosan elérhetők.</span>
) : (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => setStep("confirm")}>
Részletes elemzés kérése
</button>
<span className="hint">Még {left} képletelemzésed van.</span>
</div>
)
) : canPay ? (
step === "pay" ? (
<div className="pay-box">
<div className="pay-line">
<span>Részletes képletelemzés</span>
<strong>1 db</strong>
</div>
)}
</>
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(true)} disabled={busy}>
{busy ? "Fizetés…" : "Fizetés"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
Mégse
</button>
</div>
<p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>
</div>
) : (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => setStep("pay")}>
Részletes elemzés kérése
</button>
<Link href="/pelda" className="btn btn-ghost">
Példa megtekintése
</Link>
</div>
)
) : (
<div className="form-actions">
<Link href="/pelda" className="btn">
Példa megtekintése
</Link>
<span className="hint">A részletes elemzés fizetős; a csomagok hamarosan elérhetők.</span>
</div>
)}
</section>
);
+9
View File
@@ -17,6 +17,14 @@ export interface Me {
providers: string[];
primary_chart_id: string | null;
analyses_left: UnitBalance;
birth_change: BirthChange;
}
/** Limit on changing the own birth data (the notice text comes from the backend). */
export interface BirthChange {
limited: boolean;
next_change_at: string | null;
notice: string | null;
}
/** Detailed analyses left, per kind. */
@@ -32,6 +40,7 @@ export interface PublicConfig {
summary_model: string;
password_login: boolean;
password_min_length: number;
mock_payments: boolean;
}
export interface Position {