Persons: other people's charts with package slots, list page, switcher
- charts.kind own/person; a new person uses a 'person' unit (not refunded on delete); person packages and an unlimited entitlement; admins unlimited - a person's birth data can be corrected within an hour (admins any time) - /kepletek list with tiles, /kepletek/uj, correction page, mock person packages, chart page title switches between charts keeping the tab 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,29 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { BirthForm } from "@/app/profil/BirthForm";
|
||||
import type { BirthData } from "@/lib/types";
|
||||
|
||||
export function EditPerson({
|
||||
id,
|
||||
name,
|
||||
initial,
|
||||
}: {
|
||||
id: string;
|
||||
name: string;
|
||||
initial: BirthData & { placeName: string | null; region: string | null };
|
||||
}) {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<BirthForm
|
||||
initial={initial}
|
||||
person={{ chartId: id, name }}
|
||||
onCancel={() => router.push("/kepletek")}
|
||||
onSaved={() => {
|
||||
router.push(`/kepletek/${id}`);
|
||||
router.refresh();
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import type { Metadata } from "next";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Chart } from "@/lib/types";
|
||||
|
||||
import { EditPerson } from "./EditPerson";
|
||||
|
||||
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's 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">
|
||||
A javítás után újraszámoljuk a képletet és a rövid összefoglalót.
|
||||
</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,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<p className="muted">A személy születési adatai csak a felvételt követő egy órán belül javíthatók.</p>
|
||||
<Link href={`/kepletek/${id}`} className="btn" style={{ alignSelf: "flex-start" }}>
|
||||
Vissza a képlethez
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -3,12 +3,13 @@ import { notFound } from "next/navigation";
|
||||
|
||||
import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
|
||||
import { ChartSummary } from "@/components/ChartSummary";
|
||||
import { ChartSwitcher } from "@/components/ChartSwitcher";
|
||||
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
|
||||
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
||||
import { Tabs } from "@/components/Tabs";
|
||||
import { ASPECTS, ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
||||
import { backendGet, requireMe } from "@/lib/server";
|
||||
import type { Analysis, Chart, PublicConfig } from "@/lib/types";
|
||||
import type { Analysis, Chart, ChartListItem, PublicConfig } from "@/lib/types";
|
||||
|
||||
export const metadata: Metadata = { title: "Képlet" };
|
||||
|
||||
@@ -21,11 +22,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
const { id } = await params;
|
||||
const me = await requireMe(`/kepletek/${id}`);
|
||||
if (!UUID.test(id)) notFound();
|
||||
const [chart, analyses, config] = await Promise.all([
|
||||
const [chart, analyses, config, chartList] = await Promise.all([
|
||||
backendGet<Chart>(`/v1/charts/${id}`),
|
||||
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
|
||||
backendGet<PublicConfig>("/v1/config"),
|
||||
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
|
||||
]);
|
||||
const charts = chartList?.charts ?? [];
|
||||
if (!chart) notFound();
|
||||
const list = analyses?.analyses ?? [];
|
||||
const summary = list.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
|
||||
@@ -43,7 +46,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
||||
return (
|
||||
<main className="page" style={{ maxWidth: 1180 }}>
|
||||
<div className="page-head">
|
||||
<h1>{chart.is_primary ? "Születési képletem" : chart.label}</h1>
|
||||
<ChartSwitcher
|
||||
title={chart.is_primary ? "Születési képletem" : chart.label}
|
||||
currentId={chart.id}
|
||||
own={charts.find((c) => c.is_primary) ?? null}
|
||||
persons={charts.filter((c) => c.kind === "person")}
|
||||
canAdd={me.persons.left !== 0}
|
||||
/>
|
||||
<p className="muted">
|
||||
{formatBirthDate(chart.birth_data.date)}
|
||||
{timeKnown ? `, ${result.time.local.slice(11, 16)} (UTC${result.time.utc_offset}${result.time.dst ? ", nyári idő" : ""})` : ", ismeretlen időpont"}
|
||||
|
||||
Reference in New Issue
Block a user