"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; 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; } /** * 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); if (editing || !chart) { return (
{chart ? (

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.

) : (

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.

)} {chart && notice &&

{notice}

} setEditing(false) : undefined} onSaved={(id) => router.push(`/kepletek/${id}`)} />
); } const { birth } = chart; const country = chart.countryCode ?? birth.country; return (
Dátum
{formatBirthDate(birth.date)}
Időpont
{birth.time ? ( <> {birth.time.slice(0, 5)}{" "} ({chart.zone}, UTC{chart.utcOffset} {chart.dst ? ", nyári idő" : ""}) ) : ( ismeretlen )}
Hely
{chart.placeName ?? birth.place ?? "–"} {chart.region && , {chart.region}} {country && , {countryName(country)}}
{chartId && ( Képlet megnyitása )}
{notice &&

{notice}

}
); }