2026-11-15 21:00:50 +00:00
|
|
|
|
"use client";
|
|
|
|
|
|
|
2026-11-16 06:37:59 +00:00
|
|
|
|
import Link from "next/link";
|
|
|
|
|
|
import { useRouter } from "next/navigation";
|
2026-11-15 21:00:50 +00:00
|
|
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
|
|
|
|
import { countryName, formatBirthDate } from "@/lib/astro";
|
|
|
|
|
|
import type { BirthData } from "@/lib/types";
|
|
|
|
|
|
|
|
|
|
|
|
import { BirthForm } from "./BirthForm";
|
|
|
|
|
|
|
|
|
|
|
|
export interface SavedBirth {
|
|
|
|
|
|
birth: BirthData;
|
|
|
|
|
|
placeName: string | null;
|
|
|
|
|
|
region: string | null;
|
|
|
|
|
|
countryCode: string | null;
|
|
|
|
|
|
zone: string;
|
|
|
|
|
|
utcOffset: string;
|
|
|
|
|
|
dst: boolean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-16 06:37:59 +00:00
|
|
|
|
/** 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();
|
2026-11-15 21:00:50 +00:00
|
|
|
|
const [editing, setEditing] = useState(chart === null);
|
|
|
|
|
|
|
|
|
|
|
|
if (editing || !chart) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="field" style={{ gap: 16 }}>
|
|
|
|
|
|
{chart ? (
|
|
|
|
|
|
<p className="muted">
|
|
|
|
|
|
A javított adatokból új képlet készül, és az lesz a saját képleted. A régit a meglévő összevetések miatt
|
|
|
|
|
|
megtartjuk.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<p className="muted">
|
|
|
|
|
|
Add meg a születésed adatait. Ebből számoljuk a képletedet; a helyi időt és az akkori időzónát (nyári
|
|
|
|
|
|
időszámítást) a születési hely alapján magunk határozzuk meg.
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<BirthForm
|
|
|
|
|
|
initial={chart ? { ...chart.birth, placeName: chart.placeName, region: chart.region } : null}
|
|
|
|
|
|
onCancel={chart ? () => setEditing(false) : undefined}
|
2026-11-16 06:37:59 +00:00
|
|
|
|
onSaved={(id) => router.push(`/kepletek/${id}`)}
|
2026-11-15 21:00:50 +00:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { birth } = chart;
|
|
|
|
|
|
const country = chart.countryCode ?? birth.country;
|
|
|
|
|
|
return (
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<div className="field">
|
2026-11-15 21:00:50 +00:00
|
|
|
|
<div className="card-head" style={{ alignItems: "flex-start" }}>
|
|
|
|
|
|
<dl className="facts">
|
|
|
|
|
|
<dt>Dátum</dt>
|
|
|
|
|
|
<dd>{formatBirthDate(birth.date)}</dd>
|
|
|
|
|
|
<dt>Időpont</dt>
|
|
|
|
|
|
<dd>
|
|
|
|
|
|
{birth.time ? (
|
|
|
|
|
|
<>
|
|
|
|
|
|
{birth.time.slice(0, 5)}{" "}
|
|
|
|
|
|
<span className="muted">
|
|
|
|
|
|
({chart.zone}, UTC{chart.utcOffset}
|
|
|
|
|
|
{chart.dst ? ", nyári idő" : ""})
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<span className="muted">ismeretlen</span>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
<dt>Hely</dt>
|
|
|
|
|
|
<dd>
|
|
|
|
|
|
{chart.placeName ?? birth.place ?? "–"}
|
|
|
|
|
|
{chart.region && <span className="muted">, {chart.region}</span>}
|
|
|
|
|
|
{country && <span className="muted">, {countryName(country)}</span>}
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
</dl>
|
2026-11-16 06:37:59 +00:00
|
|
|
|
<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>
|
2026-11-15 21:00:50 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|