Inviting a person to compare charts
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:
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user