The person edit form sent the birth data with every save, so a new name alone
recalculated the chart, deleted its analyses and comparisons and queued a new
summary. Now the backend ignores birth data equal to the stored one (and keeps
everything when a recalculation gives the same chart), and the form sends it
only when it changed. The name can be changed after the correction window too
("Átnevezés" on the person card).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { notFound } from "next/navigation";
|
|
|
|
import { backendGet, requireMe } from "@/lib/server";
|
|
import type { Chart } from "@/lib/types";
|
|
|
|
import { EditPerson } from "./EditPerson";
|
|
import { RenamePerson } from "./RenamePerson";
|
|
|
|
export const metadata: Metadata = { title: "Adatok javítása" };
|
|
|
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
/** Correcting a person: name any time, birth data within an hour of adding them (admins any time). */
|
|
export default async function EditPersonPage({ params }: { params: Promise<{ id: string }> }) {
|
|
const { id } = await params;
|
|
const me = await requireMe(`/kepletek/${id}/javitas`);
|
|
if (!UUID.test(id)) notFound();
|
|
const chart = await backendGet<Chart>(`/v1/charts/${id}`);
|
|
if (!chart || chart.kind !== "person") notFound();
|
|
const editable =
|
|
me.user.roles.includes("admin") || (chart.editable_until !== null && Date.parse(chart.editable_until) > Date.now());
|
|
|
|
return (
|
|
<main className="page">
|
|
<div className="page-head">
|
|
<h1>{chart.label} adatai</h1>
|
|
<p className="muted">
|
|
{editable
|
|
? "Ha a születési adatokon változtatsz, újraszámoljuk a képletet és a rövid összefoglalót. A név módosítása a képletet és az elemzéseket nem érinti."
|
|
: "A név bármikor módosítható; a képlet és az elemzések maradnak."}
|
|
</p>
|
|
</div>
|
|
<section className="card" aria-label="Születési adatok">
|
|
{editable ? (
|
|
<EditPerson
|
|
id={id}
|
|
name={chart.label}
|
|
initial={{
|
|
...chart.birth_data,
|
|
placeName: chart.chart.location.place?.name ?? null,
|
|
region: chart.chart.location.place?.region ?? null,
|
|
}}
|
|
/>
|
|
) : (
|
|
<>
|
|
<RenamePerson id={id} name={chart.label} />
|
|
<p className="hint">A születési adatok csak a felvételt követő egy órán belül javíthatók.</p>
|
|
</>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|