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:
@@ -16,15 +16,22 @@ const ERRORS: Record<string, string> = {
|
||||
invalid_date: "Érvénytelen dátum.",
|
||||
};
|
||||
|
||||
/** Someone else's chart: added with a name, or (with `chartId`) corrected. */
|
||||
export type PersonTarget = { chartId?: string; name?: string };
|
||||
|
||||
export function BirthForm({
|
||||
initial,
|
||||
person,
|
||||
onCancel,
|
||||
onSaved,
|
||||
}: {
|
||||
initial: Initial;
|
||||
/** Not given: the user's own birth data. */
|
||||
person?: PersonTarget;
|
||||
onCancel?: () => void;
|
||||
onSaved: (chartId: string) => void;
|
||||
}) {
|
||||
const [name, setName] = useState(person?.name ?? "");
|
||||
const [date, setDate] = useState(initial?.date ?? "");
|
||||
const [time, setTime] = useState(initial?.time?.slice(0, 5) ?? "");
|
||||
const [timeUnknown, setTimeUnknown] = useState(initial ? !initial.time : false);
|
||||
@@ -49,24 +56,29 @@ export function BirthForm({
|
||||
async function submit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
if (person && !name.trim()) return setError("Add meg a nevét.");
|
||||
if (!date) return setError("Add meg a születési dátumot.");
|
||||
if (!timeUnknown && !time) return setError("Add meg a születési időt, 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 saved = await api<{ id: string }>("/charts", {
|
||||
body: {
|
||||
label: "Saját képlet",
|
||||
is_primary: true,
|
||||
birth: {
|
||||
date,
|
||||
...(timeUnknown ? {} : { time }),
|
||||
country,
|
||||
geonames_id: place.geonames_id,
|
||||
...(ambiguous ? { ambiguous_time: ambiguity } : {}),
|
||||
},
|
||||
},
|
||||
});
|
||||
const birth = {
|
||||
date,
|
||||
...(timeUnknown ? {} : { time }),
|
||||
country,
|
||||
geonames_id: place.geonames_id,
|
||||
...(ambiguous ? { ambiguous_time: ambiguity } : {}),
|
||||
};
|
||||
const saved = person?.chartId
|
||||
? await api<{ id: string }>(`/charts/${person.chartId}`, {
|
||||
method: "PATCH",
|
||||
body: { label: name.trim(), birth },
|
||||
})
|
||||
: await api<{ id: string }>("/charts", {
|
||||
body: person
|
||||
? { label: name.trim(), is_primary: false, birth }
|
||||
: { label: "Saját képlet", is_primary: true, birth },
|
||||
});
|
||||
onSaved(saved.id);
|
||||
} catch (err) {
|
||||
if (err instanceof ApiError && err.code === "ambiguous_local_time") {
|
||||
@@ -84,6 +96,20 @@ export function BirthForm({
|
||||
|
||||
return (
|
||||
<form onSubmit={submit} className="field" style={{ gap: 18 }} noValidate>
|
||||
{person && (
|
||||
<div className="field" style={{ maxWidth: 420 }}>
|
||||
<label htmlFor="person-name">Név</label>
|
||||
<input
|
||||
id="person-name"
|
||||
className="inp"
|
||||
value={name}
|
||||
maxLength={100}
|
||||
autoComplete="off"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="grid-2">
|
||||
<div className="field">
|
||||
<label htmlFor="birth-date">Születési dátum</label>
|
||||
@@ -132,7 +158,7 @@ export function BirthForm({
|
||||
{ambiguous && (
|
||||
<fieldset className="field" style={{ border: 0, padding: 0, margin: 0 }}>
|
||||
<legend className="label" style={{ marginBottom: 8 }}>
|
||||
Melyik időpontban születtél?
|
||||
{person ? "Melyik időpontban született?" : "Melyik időpontban születtél?"}
|
||||
</legend>
|
||||
<label className="check">
|
||||
<input type="radio" name="ambiguity" checked={ambiguity === "earlier"} onChange={() => setAmbiguity("earlier")} />
|
||||
@@ -152,7 +178,7 @@ export function BirthForm({
|
||||
)}
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
{busy ? "Számolás…" : "Mentés és képlet számítása"}
|
||||
{busy ? "Számolás…" : person?.chartId ? "Javítás mentése" : "Mentés és képlet számítása"}
|
||||
</button>
|
||||
{onCancel && (
|
||||
<button type="button" className="btn btn-ghost" onClick={onCancel} disabled={busy}>
|
||||
|
||||
@@ -46,6 +46,10 @@ export default async function ProfilePage() {
|
||||
<dd>
|
||||
{me.analyses_left.natal} képlet, {me.analyses_left.synastry} szinasztria
|
||||
</dd>
|
||||
<dt>Személyek</dt>
|
||||
<dd>
|
||||
{me.persons.unlimited ? `${me.persons.used} felvéve, korlátlan` : `${me.persons.used} / ${me.persons.limit} hely`}
|
||||
</dd>
|
||||
<dt>Tag óta</dt>
|
||||
<dd>{formatDate(user.created_at)}</dd>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user