"use client"; import Link from "next/link"; import { useMemo, useRef, useState } from "react"; import { CountrySelect, PlaceSearch } from "@/app/profil/BirthForm"; import { ZODIAC_BY_ID } from "@/content/zodiac"; import { ApiError, api, errorText } from "@/lib/api"; import { SIGNS } from "@/lib/astro"; import { MONTHS, composeDate, composeTime, daysIn } from "@/lib/birth"; import type { Place } from "@/lib/types"; interface Sign { sign: string; degree: number | null; uncertain: boolean; } interface Result { sun: Sign; moon: Sign; ascendant: Sign | null; time_known: boolean; } const ERRORS: Record = { place_not_found: "Nem találjuk ezt a települést. Válassz a listából.", nonexistent_local_time: "Ez az időpont az óraátállítás miatt nem létezett ezen a napon (az órát előreállították). Ellenőrizd a születési időt.", invalid_date: "Érvénytelen dátum.", too_many_requests: "Erről a címről most túl sok számítás érkezett. Próbáld újra egy óra múlva.", }; function SignCard({ label, anchor, sign, note }: { label: string; anchor: string; sign: Sign; note?: string }) { const z = ZODIAC_BY_ID.get(sign.sign); const s = SIGNS[sign.sign]; return (
{label}
{s?.hu ?? sign.sign} {sign.degree !== null && {sign.degree}°}
{note && (

{note}

)} {z && ( Mit jelent? → )}
); } /** The public Sun, Moon and Ascendant calculator: a calculation only, nothing is saved and no AI is used. */ export function SignCalculator() { const [year, setYear] = useState(""); const [month, setMonth] = useState(""); const [day, setDay] = useState(""); const [hour, setHour] = useState(""); const [minute, setMinute] = useState(""); const [timeUnknown, setTimeUnknown] = useState(false); const [country, setCountry] = useState("HU"); const [place, setPlace] = useState(null); const [ambiguous, setAmbiguous] = useState(false); const [ambiguity, setAmbiguity] = useState<"earlier" | "later">("earlier"); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [result, setResult] = useState(null); const minuteRef = useRef(null); const resultRef = useRef(null); const today = useMemo(() => new Date().toISOString().slice(0, 10), []); async function submit(e: React.FormEvent) { e.preventDefault(); setError(null); const date = composeDate(year, month, day); const time = composeTime(hour, minute); if (!date) return setError("Ellenőrizd a dátumot: az év négy számjegy, és a nap legyen az adott hónapban."); if (date > today) return setError("A születési dátum nem lehet a jövőben."); if (!timeUnknown && !time) return setError("Add meg a születési időt (óra 0–23, perc 0–59), vagy jelöld, hogy nem tudod."); if (!place) return setError("Válaszd ki a születési helyet a listából."); setBusy(true); try { const r = await api("/public/signs", { body: { date, ...(timeUnknown ? {} : { time }), country, geonames_id: place.geonames_id, ...(ambiguous ? { ambiguous_time: ambiguity } : {}), }, }); setResult(r); requestAnimationFrame(() => resultRef.current?.scrollIntoView({ behavior: "smooth", block: "start", }), ); } catch (err) { if (err instanceof ApiError && err.code === "ambiguous_local_time") { setAmbiguous(true); setError( "Ez az időpont az óraátállítás miatt kétszer is előfordult ezen a napon. Válaszd ki, melyikben születtél.", ); } else { setError(err instanceof ApiError ? (ERRORS[err.code] ?? errorText(err)) : errorText(err)); } } finally { setBusy(false); } } const uncertain = "A születési idő nélkül ez a jegy a nap elején vagy végén a szomszédos jegy is lehetett."; return ( <>
Születési dátum
setYear(e.target.value.replace(/\D/g, ""))} />
Születési idő (helyi idő)
{ const v = e.target.value.replace(/\D/g, ""); setHour(v); setAmbiguous(false); if (v.length === 2 || (v.length === 1 && Number(v) > 2)) minuteRef.current?.focus(); }} /> { setMinute(e.target.value.replace(/\D/g, "")); setAmbiguous(false); }} />
{ setCountry(c); setPlace(null); }} />
{ambiguous && (
Melyik időpontban születtél?
)} {error && (

{error}

)}
Ingyenes, belépés nélkül. Az adataidat nem mentjük el.
{result && (
{result.ascendant ? ( ) : (
Aszcendens

Az aszcendens percről percre változik, ezért kiszámolásához pontos születési idő kell.

)}

Ez csak három pont a képletedből

A teljes születési képleted mind a tíz bolygót, a házakat és a fényszögeket is mutatja, és ingyen kapsz hozzá egy rövid, személyre szabott összefoglalót.

A teljes képletem ingyen
)} ); }