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