Yearly forecast: solar return, transits, progressions, profection, eclipses
- astro-engine: forecast module (solar return moment, slow-planet transits
with exact dates and periods, natal house ingresses, secondary
progressions, annual profection, eclipses via Swiss Ephemeris)
- horoscope-api: POST /v1/forecast, solar return chart cast for the place
of the birthday
- backend: forecasts table, /v1/charts/{id}/forecasts, /v1/forecasts/{id}
and its analyses using a new 'forecast' unit; current year of life open,
the next one 30 days before the birthday
- packages: Páros and Család include forecasts (6 000 / 11 000 Ft),
+1 éves előrejelzés add-on 2 500 Ft; Egy elemzés unchanged
- worker and prompt: forecast kind with five sections and forecast rules
(trends, no event predictions); no birth data, place or exact age sent
- frontend: /kepletek/{id}/elorejelzes with the solar return wheel, the
keys of the year, a monthly timeline, transit list and detailed forecast
- data export: forecasts added, model name removed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { CountrySelect, PlaceSearch } from "@/app/profil/BirthForm";
|
||||
import { api, errorText } from "@/lib/api";
|
||||
import type { ForecastDetail, Place } from "@/lib/types";
|
||||
|
||||
/**
|
||||
* Calculates a year: which year (when two are open) and where the person is
|
||||
* on the birthday (the solar return chart is cast for that place).
|
||||
*/
|
||||
export function ForecastStart({
|
||||
chartId,
|
||||
years,
|
||||
birthPlace,
|
||||
timeKnown,
|
||||
compact = false,
|
||||
}: {
|
||||
chartId: string;
|
||||
years: number[];
|
||||
birthPlace: string | null;
|
||||
timeKnown: boolean;
|
||||
compact?: boolean;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [year, setYear] = useState(years[0]);
|
||||
const [elsewhere, setElsewhere] = useState(false);
|
||||
const [country, setCountry] = useState("HU");
|
||||
const [place, setPlace] = useState<Place | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function submit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (elsewhere && !place) return setError("Válaszd ki a települést a listából.");
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const body: Record<string, unknown> = { year };
|
||||
if (elsewhere && place) body.location = { country, geonames_id: place.geonames_id, place: place.name };
|
||||
const f = await api<ForecastDetail>(`/charts/${chartId}/forecasts`, { body });
|
||||
router.push(`/kepletek/${chartId}/elorejelzes?f=${f.id}`);
|
||||
router.refresh();
|
||||
} catch (err) {
|
||||
setError(errorText(err));
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form className={compact ? "field" : "card field"} onSubmit={submit} style={{ gap: 14 }}>
|
||||
{!compact && (
|
||||
<>
|
||||
<span className="eyebrow">Éves előrejelzés</span>
|
||||
<h2>Mit hoz az éved?</h2>
|
||||
<p className="muted">
|
||||
Egy év születésnaptól születésnapig. Az év képlete a szolár: az a pillanat, amikor a Nap visszatér a
|
||||
születéskori helyére. Ehhez jönnek a lassú bolygók tranzitjai pontos dátumokkal, a progresszív Hold, az év ura
|
||||
és a fogyatkozások. A számítás és az idővonal ingyenes.
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
{years.length > 1 && (
|
||||
<fieldset className="field" style={{ border: 0, padding: 0, margin: 0 }}>
|
||||
<legend className="label" style={{ marginBottom: 8 }}>
|
||||
Melyik év?
|
||||
</legend>
|
||||
{years.map((y) => (
|
||||
<label key={y} className="check">
|
||||
<input type="radio" name="year" checked={year === y} onChange={() => setYear(y)} />
|
||||
{y === years[0] ? `A mostani év (${y}-es születésnaptól)` : `A következő év (${y}-es születésnaptól)`}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
{timeKnown && (
|
||||
<fieldset className="field" style={{ border: 0, padding: 0, margin: 0 }}>
|
||||
<legend className="label" style={{ marginBottom: 8 }}>
|
||||
Hol vagy a születésnapodon?
|
||||
</legend>
|
||||
<label className="check">
|
||||
<input type="radio" name="where" checked={!elsewhere} onChange={() => setElsewhere(false)} />
|
||||
A születési helyemen{birthPlace ? ` (${birthPlace})` : ""}
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="radio" name="where" checked={elsewhere} onChange={() => setElsewhere(true)} />
|
||||
Máshol (lakóhely, nyaralás)
|
||||
</label>
|
||||
<span className="hint">
|
||||
A szolár képlet házai attól függnek, hol tartózkodsz a születésnapod pillanatában. Ha nem tudod, add meg
|
||||
a lakóhelyed.
|
||||
</span>
|
||||
</fieldset>
|
||||
)}
|
||||
{timeKnown && elsewhere && (
|
||||
<div className="grid-2">
|
||||
<CountrySelect
|
||||
value={country}
|
||||
onChange={(c) => {
|
||||
setCountry(c);
|
||||
setPlace(null);
|
||||
}}
|
||||
/>
|
||||
<PlaceSearch country={country} value={place} onChange={setPlace} />
|
||||
</div>
|
||||
)}
|
||||
{!timeKnown && (
|
||||
<p className="hint">
|
||||
A születési idő ismeretlen, ezért szolár képlet és az év ura nem számolható; az előrejelzés a tranzitokra és a
|
||||
progresszióra épül.
|
||||
</p>
|
||||
)}
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
{busy ? "Számolás…" : compact ? "Kiszámítás" : "Előrejelzés kiszámítása"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { ChartWheel } from "@/components/ChartWheel";
|
||||
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
|
||||
import { ForecastKeys, ForecastTimeline, ForecastTransits, longDay } from "@/components/ForecastViews";
|
||||
import { Tabs } from "@/components/Tabs";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Analysis, Chart, ForecastDetail, ForecastList, PublicConfig } from "@/lib/types";
|
||||
|
||||
import { ForecastStart } from "./ForecastStart";
|
||||
|
||||
export const metadata: Metadata = { title: "Éves előrejelzés" };
|
||||
|
||||
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
/** One year of a chart: the solar return, the year's keys, the timeline and the detailed forecast. */
|
||||
export default async function ForecastPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
searchParams: Promise<{ f?: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const { f } = await searchParams;
|
||||
const me = await requireMe(`/kepletek/${id}/elorejelzes`);
|
||||
if (!UUID.test(id)) notFound();
|
||||
const [chart, list, config] = await Promise.all([
|
||||
backendGet<Chart>(`/v1/charts/${id}`),
|
||||
backendGet<ForecastList>(`/v1/charts/${id}/forecasts`),
|
||||
backendGet<PublicConfig>("/v1/config"),
|
||||
]);
|
||||
if (!chart || !list) notFound();
|
||||
const chosenId = f && UUID.test(f) ? f : (list.forecasts[0]?.id ?? null);
|
||||
const [forecast, analyses] = chosenId
|
||||
? await Promise.all([
|
||||
backendGet<ForecastDetail>(`/v1/forecasts/${chosenId}`),
|
||||
backendGet<{ analyses: Analysis[] }>(`/v1/forecasts/${chosenId}/analyses`),
|
||||
])
|
||||
: [null, null];
|
||||
const detailed = (analyses?.analyses ?? []).find((a) => a.status !== "failed") ?? analyses?.analyses[0] ?? null;
|
||||
const name = chart.is_primary ? "Az éved" : `${chart.label} éve`;
|
||||
const sr = forecast?.result.solar_return ?? null;
|
||||
const fc = forecast?.result.forecast;
|
||||
const others = list.forecasts.filter((x) => x.id !== forecast?.id);
|
||||
|
||||
return (
|
||||
<main className="page" style={{ maxWidth: 1180 }}>
|
||||
<div className="page-head">
|
||||
<p className="hint">
|
||||
<Link href={`/kepletek/${chart.id}`}>← {chart.is_primary ? "Születési képletem" : chart.label}</Link>
|
||||
</p>
|
||||
<h1>{forecast ? `${name}: ${forecast.year}–${forecast.year + 1}` : "Éves előrejelzés"}</h1>
|
||||
{forecast && fc && (
|
||||
<p className="muted">
|
||||
{longDay(fc.start)} – {longDay(fc.end)} · {forecast.place ?? "születési hely"}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!forecast && list.years.length > 0 && (
|
||||
<ForecastStart
|
||||
chartId={chart.id}
|
||||
years={list.years}
|
||||
birthPlace={list.birth_place}
|
||||
timeKnown={list.time_known}
|
||||
/>
|
||||
)}
|
||||
{!forecast && list.years.length === 0 && (
|
||||
<p className="card muted">Az első születésnap előtt még nincs éves előrejelzés.</p>
|
||||
)}
|
||||
|
||||
{forecast && fc && (
|
||||
<>
|
||||
<section className="chart-layout" aria-label="Szolár képlet">
|
||||
{sr ? (
|
||||
<div className="card chart-wheel-card">
|
||||
<ChartWheel chart={sr} timeKnown title="Szolár képlet" />
|
||||
<p className="hint">
|
||||
Szolár képlet: {longDay(sr.local_time.slice(0, 10))} {sr.local_time.slice(11, 16)} helyi idő
|
||||
szerint, {forecast.place}. A Nap ekkor ér vissza pontosan a születéskori helyére.
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="card">
|
||||
<p className="muted">
|
||||
Szolár képlet nincs, mert a születési idő ismeretlen: a Nap visszatérésének pillanata így akár fél napot
|
||||
is tévedhet. Az előrejelzés a tranzitokra és a progresszióra épül.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<div className="field chart-side">
|
||||
<ForecastKeys forecast={fc} solarReturn={sr} />
|
||||
{(list.years.length > 0 || others.length > 0) && (
|
||||
<details className="card">
|
||||
<summary>Másik év vagy helyszín</summary>
|
||||
{others.length > 0 && (
|
||||
<ul className="plain-list">
|
||||
{others.map((o) => (
|
||||
<li key={o.id}>
|
||||
<Link href={`/kepletek/${chart.id}/elorejelzes?f=${o.id}`}>
|
||||
{o.year}–{o.year + 1} · {o.place ?? "születési hely"}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{list.years.length > 0 && (
|
||||
<ForecastStart
|
||||
chartId={chart.id}
|
||||
years={list.years}
|
||||
birthPlace={list.birth_place}
|
||||
timeKnown={list.time_known}
|
||||
compact
|
||||
/>
|
||||
)}
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="card chart-tabs" aria-label="Előrejelzés">
|
||||
<Tabs
|
||||
label="Előrejelzés részletei"
|
||||
tabs={[
|
||||
{
|
||||
id: "elemzes",
|
||||
label: "Előrejelzés",
|
||||
content: (
|
||||
<DetailedAnalysis
|
||||
target={{ kind: "forecast", forecastId: forecast.id }}
|
||||
initial={detailed}
|
||||
left={me.analyses_left.forecast}
|
||||
isAdmin={me.user.roles.includes("admin")}
|
||||
canPay={config?.mock_payments ?? false}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ id: "idovonal", label: "Idővonal", content: <ForecastTimeline forecast={fc} /> },
|
||||
{ id: "tranzitok", label: "Tranzitok", content: <ForecastTransits forecast={fc} /> },
|
||||
]}
|
||||
/>
|
||||
</section>
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -118,6 +118,16 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<Link href={`/kepletek/${chart.id}/elorejelzes`} className="card persons-tile">
|
||||
<span className="eyebrow">Éves előrejelzés</span>
|
||||
<strong>{chart.is_primary ? "Mit hoz az éved?" : `Mit hoz ${chart.label} éve?`}</strong>
|
||||
<span className="muted">
|
||||
Szolár képlet, tranzitok pontos dátumokkal, progresszió: egy év születésnaptól születésnapig.
|
||||
</span>
|
||||
<span className="persons-tile-arrow" aria-hidden="true">
|
||||
→
|
||||
</span>
|
||||
</Link>
|
||||
{!chart.is_primary && own && (
|
||||
<div className="card compare-tile">
|
||||
<span className="eyebrow">Összevetés</span>
|
||||
|
||||
Reference in New Issue
Block a user