Inviting a person to compare charts
CI / test (push) Successful in 1m15s
CI / build (push) Successful in 5m27s
CI / deploy (push) Skipped

The new person page offers 'Adatok megadása' (typed-in data, uses a slot)
or 'Meghívom': a 'how compatible are we?' link with an optional name,
e-mail and message (no links, 300 chars), shareable by copy, the phone's
share menu, WhatsApp or Facebook. With an address we e-mail it too (at most
10 a day per user, opted-out addresses skipped, unsubscribe link included).
The invitee lands on /meghivas/<token>, signs in, gives their own birth data
if needed and gets the comparison; the inviter is told and lists pending
invitations (revocable) on the persons page. No person slot is used.

Also: the accepted e-mail links to /osszevetesek/<id>, and the cross grid no
longer breaks on another user's chart (no highlights there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-19 10:12:51 +00:00
co-authored by Claude Opus 5.5
parent 7b23d71526
commit 4f09aac3f5
16 changed files with 820 additions and 39 deletions
+16
View File
@@ -743,3 +743,19 @@ a.pair-row:hover strong { color: var(--gold); }
.promo-form .promo-note, .promo-form .btn { grid-column: 1 / -1; }
}
@media (max-width: 640px) { .who { flex-wrap: wrap; gap: 8px 12px; } }
/* New person: typed-in data or an invitation */
.mode-switch { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.mode-option {
display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-align: left; cursor: pointer; font: inherit;
color: var(--ink); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px;
}
.mode-option strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.mode-option span { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.mode-option:hover { border-color: #5a6790; }
.mode-option[aria-selected="true"] { border-color: var(--gold); background: rgba(217, 180, 106, 0.08); }
.mode-option[aria-selected="true"] strong { color: var(--gold); }
.invite-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.invite-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.invite-list li:last-child { border-bottom: 0; }
.invite-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; }
@@ -0,0 +1,63 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { BirthForm } from "@/app/profil/BirthForm";
import { api, errorText } from "@/lib/api";
/** The logged-in invitee: gives their own birth data if needed, then the comparison is made. */
export function AcceptInvite({ token, hasOwnChart }: { token: string; hasOwnChart: boolean }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [needsChart, setNeedsChart] = useState(!hasOwnChart);
async function accept() {
setBusy(true);
setError(null);
try {
const s = await api<{ id: string }>("/invites/accept", { body: { token } });
router.push(`/osszevetesek/${s.id}`);
router.refresh();
} catch (e) {
setError(errorText(e));
setBusy(false);
}
}
if (needsChart) {
return (
<div className="field" style={{ gap: 12 }}>
<p>Add meg a születési adataidat: ebből készül a képleted, és ezt vetjük össze.</p>
<BirthForm
initial={null}
onSaved={() => {
setNeedsChart(false);
accept();
}}
/>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
);
}
return (
<div className="field" style={{ gap: 12 }}>
<p>A saját képleteddel vetjük össze.</p>
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={accept} disabled={busy}>
{busy ? "Készül az összevetés…" : "Összevetés elkészítése"}
</button>
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
);
}
@@ -0,0 +1,95 @@
import type { Metadata } from "next";
import Link from "next/link";
import { GoogleLogin } from "@/app/belepes/GoogleLogin";
import { Logo } from "@/components/SiteHeader";
import { formatDate } from "@/lib/astro";
import { BACKEND_URL, getMe } from "@/lib/server";
import type { PersonInviteLanding, PublicConfig } from "@/lib/types";
import { AcceptInvite } from "./AcceptInvite";
export const metadata: Metadata = {
title: "Mennyire illünk össze?",
description: "Meghívó a születési képletek összevetésére a Sorsfonalakon.",
robots: { index: false },
};
const TOKEN = /^[A-Za-z0-9_-]{8,200}$/;
async function load<T>(path: string): Promise<T | null> {
try {
const res = await fetch(`${BACKEND_URL}${path}`, { cache: "no-store" });
return res.ok ? ((await res.json()) as T) : null;
} catch {
return null;
}
}
/** A "how compatible are we?" link: who invites, login, own birth data, then the comparison. */
export default async function PersonInvitePage({ params }: { params: Promise<{ token: string }> }) {
const { token } = await params;
const valid = TOKEN.test(token);
const [invite, config, me] = await Promise.all([
valid ? load<PersonInviteLanding>(`/v1/public/invites/${token}`) : Promise.resolve(null),
load<PublicConfig>("/v1/config"),
getMe(),
]);
const who = invite?.inviter_name ?? "Valaki";
const clientId = config?.google_login.enabled ? config.google_login.client_id : null;
let body: React.ReactNode;
if (!invite) {
body = <p className="msg msg-error">Ez a meghívólink érvénytelen. Ellenőrizd, hogy a teljes linket nyitottad-e meg.</p>;
} else if (invite.status === "accepted") {
body = (
<p className="muted">
Ezt a meghívót már elfogadták. {me ? <Link href="/osszevetesek">Az összevetéseid itt vannak.</Link> : null}
</p>
);
} else if (invite.status === "expired") {
body = <p className="msg msg-error">Ez a meghívó lejárt vagy visszavonták. Kérj újat attól, aki küldte.</p>;
} else if (!me) {
body = clientId ? (
<>
<GoogleLogin clientId={clientId} target={`/meghivas/${token}`} inviteToken={token} />
<p className="hint">A fiókod az első belépéskor jön létre, bármelyik Google-fiókoddal.</p>
</>
) : (
<p className="msg msg-error">A belépés most nem érhető el. Próbáld újra később.</p>
);
} else {
body = <AcceptInvite token={token} hasOwnChart={me.primary_chart_id !== null} />;
}
return (
<>
{!me && (
<header className="site-header">
<Logo />
</header>
)}
<main className="page" style={{ maxWidth: 720 }}>
<div className="page-head">
<span className="eyebrow">Meghívó</span>
<h1>Mennyire illetek össze?</h1>
{invite && (
<p className="muted">
<strong>{who}</strong> szeretné összevetni a születési képleteteket.
</p>
)}
</div>
{invite?.message && <blockquote className="invite-quote">{invite.message}</blockquote>}
<section className="card" style={{ gap: 14 }}>
{body}
{invite?.status === "pending" && (
<p className="hint">
A saját képletedet és egy rövid elemzést ingyen kapsz. {who} az összevetést látja, a születési adataidat nem.
A meghívó {formatDate(invite.expires_at).replace(/\.$/, "")}-ig érvényes.
</p>
)}
</section>
</main>
</>
);
}
+16 -11
View File
@@ -3,6 +3,7 @@ import Link from "next/link";
import { ChartCard } from "@/components/ChartCard";
import { PersonActions } from "@/components/PersonActions";
import { PendingInvites } from "@/components/PendingInvites";
import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { ChartListItem, PublicConfig } from "@/lib/types";
@@ -46,19 +47,23 @@ export default async function PersonsPage() {
</ChartCard>
))}
{!full && (
<Link href="/szemelyek/uj" className="chart-card chart-card-new">
<span className="chart-card-plus" aria-hidden="true">
+
</span>
<strong className="chart-card-name">Új személy</strong>
<span className="muted">
{slots.unlimited ? "Korlátlan számú személy" : `Még ${slots.left} személyt vehetsz fel`}
</span>
</Link>
)}
<Link href="/szemelyek/uj" className="chart-card chart-card-new">
<span className="chart-card-plus" aria-hidden="true">
+
</span>
<strong className="chart-card-name">Új személy</strong>
<span className="muted">
{full
? "Meghívással bármikor"
: slots.unlimited
? "Adatokkal vagy meghívással"
: `Még ${slots.left} személyt vehetsz fel, vagy hívd meg`}
</span>
</Link>
</div>
<PendingInvites />
{!slots.unlimited && (
<section className="card" aria-labelledby="slots-title">
<div className="card-head">
@@ -0,0 +1,77 @@
"use client";
import Link from "next/link";
import { useState } from "react";
import { InvitePerson } from "@/components/InvitePerson";
import { NewPerson } from "./NewPerson";
/**
* Adding a person: typing in their birth data (uses a slot), or inviting
* them to compare charts (they give their own data; no slot used).
*/
export function NewPersonChooser({
canAdd,
hasOwnChart,
full,
}: {
/** A slot is free for typed-in data. */
canAdd: boolean;
/** Inviting compares with the user's own chart. */
hasOwnChart: boolean;
/** Shown instead of the form when no slot is left. */
full: React.ReactNode;
}) {
const [mode, setMode] = useState<"data" | "invite">(canAdd ? "data" : "invite");
return (
<div className="field" style={{ gap: 18 }}>
<div className="mode-switch" role="tablist" aria-label="Hogyan veszed fel?">
<button
type="button"
role="tab"
aria-selected={mode === "data"}
className="mode-option"
onClick={() => setMode("data")}
>
<strong>Adatok megadása</strong>
<span>Te írod be a születési adatait. Egy személyhelyet használ.</span>
</button>
<button
type="button"
role="tab"
aria-selected={mode === "invite"}
className="mode-option"
onClick={() => setMode("invite")}
>
<strong>Meghívom</strong>
<span>Ő adja meg a saját adatait, és megnézitek, mennyire illetek össze. Ingyenes, nem kell hozzá hely.</span>
</button>
</div>
{mode === "data" ? (
canAdd ? (
<>
<NewPerson />
<p className="hint">Az adatokat a felvételt követő egy órán belül még javíthatod, utána nem módosíthatók.</p>
</>
) : (
full
)
) : hasOwnChart ? (
<>
<InvitePerson />
<p className="hint">
A meghívott a saját képletét és rövid összefoglalóját ingyen kapja. Ti ketten az összevetést látjátok, egymás
születési adatait nem. A részletes kapcsolati elemzést bármelyikőtök kérheti egy kapcsolati elemzéssel, és
mindketten látjátok.
</p>
</>
) : (
<p className="muted">
A meghívó a saját képleteddel veti össze az övét, ezért előbb <Link href="/profil#birth">add meg a saját
születési adataidat</Link>.
</p>
)}
</div>
);
}
+14 -14
View File
@@ -4,7 +4,7 @@ import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { PublicConfig } from "@/lib/types";
import { NewPerson } from "./NewPerson";
import { NewPersonChooser } from "./NewPersonChooser";
export const metadata: Metadata = { title: "Új személy" };
@@ -18,22 +18,22 @@ export default async function NewPersonPage() {
<div className="page-head">
<h1>Új személy</h1>
<p className="muted">
Társad, családtagod, barátod: a születési adataiból elkészül a képlete és egy rövid összefoglaló.
Társad, családtagod, barátod: megadhatod a születési adatait, vagy meghívhatod, hogy ő adja meg, és megnézzétek,
mennyire illetek össze.
{!slots.unlimited && slots.left !== null && slots.left > 0 && ` Még ${slots.left} személyt vehetsz fel.`}
</p>
</div>
<section className="card" aria-label="Születési adatok">
{slots.left === 0 ? (
<>
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot.</p>
<PersonPacks canPay={config?.mock_payments ?? false} />
</>
) : (
<>
<NewPerson />
<p className="hint">Az adatokat a felvételt követő egy órán belül még javíthatod, utána nem módosíthatók.</p>
</>
)}
<section className="card" aria-label="Új személy">
<NewPersonChooser
canAdd={slots.left !== 0}
hasOwnChart={me.primary_chart_id !== null}
full={
<>
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot, vagy hívd meg.</p>
<PersonPacks canPay={config?.mock_payments ?? false} />
</>
}
/>
</section>
</main>
);
@@ -0,0 +1,170 @@
"use client";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
const MAX_MESSAGE = 300;
interface Created {
url: string;
emailed: boolean;
email: string | null;
label: string | null;
}
/**
* Invites someone to compare charts instead of typing in their birth data:
* they enter their own data, and both see the comparison (not each other's
* birth data). No person slot is used.
*/
export function InvitePerson() {
const [label, setLabel] = useState("");
const [email, setEmail] = useState("");
const [message, setMessage] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [created, setCreated] = useState<Created | null>(null);
const [copied, setCopied] = useState(false);
async function submit(e: React.FormEvent) {
e.preventDefault();
setBusy(true);
setError(null);
try {
setCreated(
await api<Created>("/invites", {
body: { label: label.trim() || null, email: email.trim() || null, message: message.trim() || null },
}),
);
} catch (err) {
setError(errorText(err));
} finally {
setBusy(false);
}
}
async function copy() {
if (!created) return;
try {
await navigator.clipboard.writeText(created.url);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch {
setError("Nem sikerült másolni; jelöld ki a linket, és másold kézzel.");
}
}
if (created) {
const text = `Nézzük meg, mennyire illünk össze! ${created.url}`;
return (
<div className="field invite-done" style={{ gap: 12 }}>
<p className="msg msg-ok" role="status">
{created.emailed
? `Elküldtük a meghívót ide: ${created.email}. A linket te is továbbküldheted.`
: created.email
? `Ez a cím nem kér levelet tőlünk, ezért nem írtunk neki. Küldd el neki te a linket.`
: "Kész a meghívó. Küldd el a linket annak, akit meghívsz."}
</p>
<div className="share-link">
<input
className="inp"
readOnly
value={created.url}
aria-label="Meghívó link"
onFocus={(e) => e.currentTarget.select()}
/>
<button type="button" className="btn btn-sm" onClick={copy}>
{copied ? "Kimásolva" : "Másolás"}
</button>
</div>
<div className="form-actions">
{typeof navigator !== "undefined" && "share" in navigator && (
<button
type="button"
className="btn btn-sm btn-primary"
onClick={() => navigator.share({ text: "Nézzük meg, mennyire illünk össze!", url: created.url }).catch(() => {})}
>
Küldés…
</button>
)}
<a className="btn btn-sm" href={`https://wa.me/?text=${encodeURIComponent(text)}`} target="_blank" rel="noopener noreferrer">
WhatsApp
</a>
<a
className="btn btn-sm"
href={`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(created.url)}`}
target="_blank"
rel="noopener noreferrer"
>
Facebook
</a>
<button type="button" className="btn btn-sm btn-ghost" onClick={() => setCreated(null)}>
Újabb meghívó
</button>
</div>
<p className="hint">
A meghívó 14 napig érvényes. Amikor elfogadja, levelet kapsz, és az összevetés megjelenik az Összevetéseid
között.
</p>
</div>
);
}
return (
<form className="field" style={{ gap: 14 }} onSubmit={submit}>
<div className="grid-2">
<div className="field">
<label htmlFor="invite-label">Kit hívsz meg?</label>
<input
id="invite-label"
className="inp"
value={label}
maxLength={80}
onChange={(e) => setLabel(e.target.value)}
placeholder="pl. Anna"
/>
<span className="hint">Csak te látod, a meghívóid között.</span>
</div>
<div className="field">
<label htmlFor="invite-email">E-mail-címe (nem kötelező)</label>
<input
id="invite-email"
className="inp"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="anna@pelda.hu"
autoComplete="off"
/>
<span className="hint">Ha megadod, levélben is elküldjük neki.</span>
</div>
</div>
<div className="field">
<label htmlFor="invite-message">Üzenet (nem kötelező)</label>
<textarea
id="invite-message"
className="inp"
rows={3}
maxLength={MAX_MESSAGE}
value={message}
onChange={(e) => setMessage(e.target.value)}
placeholder="Szia! Nézzük meg, mennyire illünk össze."
/>
<span className="hint">
{message.length}/{MAX_MESSAGE} karakter, link nélkül.
</span>
</div>
<div className="form-actions">
<button type="submit" className="btn btn-primary" disabled={busy}>
{busy ? "Készül…" : "Meghívó készítése"}
</button>
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</form>
);
}
@@ -0,0 +1,85 @@
"use client";
import Link from "next/link";
import { useCallback, useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
import { formatDate } from "@/lib/astro";
import type { PersonInvite } from "@/lib/types";
/** The user's "how compatible are we?" invitations: waiting ones (revocable) and accepted ones. */
export function PendingInvites() {
const [invites, setInvites] = useState<PersonInvite[] | null>(null);
const [error, setError] = useState<string | null>(null);
const load = useCallback(async () => {
try {
setInvites((await api<{ invites: PersonInvite[] }>("/invites")).invites);
} catch (e) {
setError(errorText(e));
}
}, []);
useEffect(() => {
load();
}, [load]);
async function revoke(i: PersonInvite) {
if (!window.confirm(`Visszavonod a meghívót${i.label ? ` (${i.label})` : ""}? A link nem fog működni.`)) return;
try {
await api(`/invites/${i.id}`, { method: "DELETE" });
await load();
} catch (e) {
setError(errorText(e));
}
}
// Waiting ones, and the accepted ones of the last 30 days.
const recent = Date.now() - 30 * 86_400_000;
const shown = (invites ?? []).filter(
(i) => i.status === "pending" || (i.status === "accepted" && i.accepted_at && Date.parse(i.accepted_at) > recent),
);
if (!error && shown.length === 0) return null;
return (
<section className="card" aria-labelledby="invites-title" style={{ gap: 12 }}>
<h2 id="invites-title">Meghívóid</h2>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<ul className="invite-list">
{shown.map((i) => (
<li key={i.id}>
<span className="invite-who">
<strong>{i.label ?? i.email ?? "Meghívó"}</strong>
{i.label && i.email && <span className="hint">{i.email}</span>}
</span>
{i.status === "pending" ? (
<>
<span className="hint">
Elküldve {formatDate(i.created_at)}, érvényes {formatDate(i.expires_at).replace(/\.$/, "")}-ig
</span>
<button type="button" className="btn btn-sm btn-ghost" onClick={() => revoke(i)}>
Visszavonás
</button>
</>
) : (
<>
<span className="hint">
Elfogadta{i.accepted_by ? `: ${i.accepted_by}` : ""} · {formatDate(i.accepted_at)}
</span>
{i.synastry_id && (
<Link href={`/osszevetesek/${i.synastry_id}`} className="btn btn-sm">
Összevetés
</Link>
)}
</>
)}
</li>
))}
</ul>
</section>
);
}
@@ -1,4 +1,5 @@
import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
import { sideTimeKnown } from "@/lib/synastry";
import type { HouseOverlay, InterAspect, Synastry, SynastryResult } from "@/lib/types";
import { GRID_POINTS, Pos } from "./ChartTables";
@@ -47,7 +48,7 @@ const GRID_ANGLES: [string, string][] = [
function gridPoints(s: Synastry["chart1"]): [string, string][] {
const present = new Set(s.chart.points.map((p) => p.id));
const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [id, POINTS[id]?.glyph ?? id]);
if (s.highlights.time_known) {
if (sideTimeKnown(s)) {
for (const [key, label] of GRID_ANGLES) if (s.chart.angles?.[key]) rows.push([key, label]);
}
return rows;
+23
View File
@@ -544,3 +544,26 @@ export interface PromoCode {
revoked_at: string | null;
redeemed_by: { email: string; name: string | null } | null;
}
/** A "how compatible are we?" invitation of the user (`GET /v1/invites`). */
export interface PersonInvite {
id: string;
chart_id: string;
label: string | null;
email: string | null;
message: string | null;
status: "pending" | "accepted" | "expired";
created_at: string;
expires_at: string;
accepted_at: string | null;
accepted_by: string | null;
synastry_id: string | null;
}
/** Landing data of a "how compatible are we?" link (`GET /v1/public/invites/{token}`). */
export interface PersonInviteLanding {
inviter_name: string | null;
message: string | null;
status: "pending" | "accepted" | "expired";
expires_at: string;
}