From a986cf4edd1a600d2f2bab1eedfb192b982ebea3 Mon Sep 17 00:00:00 2001
From: feco
Date: Mon, 23 Nov 2026 10:05:19 +0000
Subject: [PATCH] Invitation page shows its gift package; person invites:
e-mail and link only
- The admin invitation's page lists the package that comes with it (the
public invitation view returns it; the promo code stays in the e-mail).
- Inviting a person: no Facebook, WhatsApp or share-sheet buttons, only the
e-mail and copying the link.
- contents() moved to lib/packageContents so server pages can use it.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
---
services/backend/src/routes/invitations.rs | 12 ++++++++++-
services/backend/src/tests.rs | 5 +++++
services/frontend/src/app/belepes/page.tsx | 14 +++++++++++++
services/frontend/src/app/globals.css | 5 +++++
.../frontend/src/components/InvitePerson.tsx | 21 -------------------
.../frontend/src/components/PackageCards.tsx | 13 +-----------
services/frontend/src/lib/packageContents.ts | 13 ++++++++++++
services/frontend/src/lib/types.ts | 2 ++
8 files changed, 51 insertions(+), 34 deletions(-)
create mode 100644 services/frontend/src/lib/packageContents.ts
diff --git a/services/backend/src/routes/invitations.rs b/services/backend/src/routes/invitations.rs
index 0025eb0..0cb84be 100644
--- a/services/backend/src/routes/invitations.rs
+++ b/services/backend/src/routes/invitations.rs
@@ -552,6 +552,7 @@ pub async fn preview(
pub async fn public_view(State(state): St, Path(token): Path) -> ApiResult> {
#[derive(sqlx::FromRow)]
struct Landing {
+ id: Uuid,
inviter: Option,
message: Option,
expires_at: OffsetDateTime,
@@ -559,7 +560,7 @@ pub async fn public_view(State(state): St, Path(token): Path) -> ApiResu
revoked_at: Option,
}
let l: Landing = sqlx::query_as(
- "SELECT u.display_name AS inviter, i.message, i.expires_at, i.accepted_at, i.revoked_at \
+ "SELECT i.id, u.display_name AS inviter, i.message, i.expires_at, i.accepted_at, i.revoked_at \
FROM invitation_tokens t JOIN invitations i ON i.id = t.invitation_id \
LEFT JOIN users u ON u.id = i.invited_by WHERE t.token_hash = $1",
)
@@ -567,7 +568,16 @@ pub async fn public_view(State(state): St, Path(token): Path) -> ApiResu
.fetch_optional(&state.db)
.await?
.ok_or(ApiError::NotFound("invitation"))?;
+ // The package that comes with it (only admins attach one); its code stays in the e-mail.
+ let gift: Option = sqlx::query_scalar(
+ "SELECT package FROM promo_codes WHERE invitation_id = $1 AND redeemed_at IS NULL AND revoked_at IS NULL",
+ )
+ .bind(l.id)
+ .fetch_optional(&state.db)
+ .await?;
+ let gift = gift.as_deref().and_then(packages::find).map_or(Value::Null, |p| p.view());
Ok(Json(json!({
+ "gift": gift,
"inviter_name": l.inviter,
"message": l.message,
"status": status(l.accepted_at, l.revoked_at, l.expires_at),
diff --git a/services/backend/src/tests.rs b/services/backend/src/tests.rs
index ff99f03..2b6a61e 100644
--- a/services/backend/src/tests.rs
+++ b/services/backend/src/tests.rs
@@ -1772,6 +1772,7 @@ async fn invitation_only_signup(pool: PgPool) {
);
let r = app.get(&format!("/v1/public/invitations/{guest_token}"), None).await;
assert_eq!((r.body["inviter_name"].as_str(), r.body["status"].as_str()), (Some("Admin"), Some("pending")));
+ assert_eq!(r.body["gift"], Value::Null);
// a resend: not too soon, then with a new link; the old one keeps working
let r = app.post(&format!("/v1/admin/invitations/{guest_id}/resend"), Some(&admin), json!({})).await;
@@ -2340,6 +2341,10 @@ async fn an_invitation_brings_its_package_and_codes_fill_up(pool: PgPool) {
);
let list = app.get("/v1/admin/invitations", Some(&admin)).await.body;
assert_eq!(list["invitations"][0]["package"]["name"], "Páros");
+ // so does the invitation's page (without the code)
+ let page = app.get(&format!("/v1/public/invitations/{guest_token}"), None).await.body;
+ assert_eq!((&page["gift"]["name"], &page["gift"]["id"]), (&json!("Páros"), &json!("couple")), "{page}");
+ assert!(!page.to_string().contains(guest["promo_code"].as_str().unwrap()));
// revoking an invitation withdraws its code
let r = app.call("DELETE", &format!("/v1/admin/invitations/{other_id}"), Some(&admin), None).await;
diff --git a/services/frontend/src/app/belepes/page.tsx b/services/frontend/src/app/belepes/page.tsx
index 93650e2..41b8291 100644
--- a/services/frontend/src/app/belepes/page.tsx
+++ b/services/frontend/src/app/belepes/page.tsx
@@ -6,6 +6,7 @@ import { Logo } from "@/components/SiteHeader";
import { ZodiacWheel } from "@/components/ZodiacWheel";
import { BACKEND_URL, getMe } from "@/lib/server";
import { formatDate } from "@/lib/astro";
+import { contents } from "@/lib/packageContents";
import type { InvitationLanding, PublicConfig } from "@/lib/types";
import { AppleLogin } from "./AppleLogin";
@@ -79,6 +80,19 @@ function InvitationCard({
{invitation.inviter_name ? {invitation.inviter_name} : "Valaki"} meghívott a Sorsfonalakra.
{invitation.message &&
{invitation.message}
}
+ {invitation.gift && (
+
+
+ Ajándékba kapod a „{invitation.gift.name}” csomagot, a regisztrációval magától
+ jóváíródik:
+
@@ -79,26 +78,6 @@ export function InvitePerson() {
- {typeof navigator !== "undefined" && "share" in navigator && (
-
- )}
-
- WhatsApp
-
-
- Facebook
-
diff --git a/services/frontend/src/components/PackageCards.tsx b/services/frontend/src/components/PackageCards.tsx
index 34ce334..bdea588 100644
--- a/services/frontend/src/components/PackageCards.tsx
+++ b/services/frontend/src/components/PackageCards.tsx
@@ -5,22 +5,11 @@ import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
+import { contents } from "@/lib/packageContents";
import type { Package, PayMethod, PublicConfig } from "@/lib/types";
export const huf = (n: number) => `${n.toLocaleString("hu-HU")} Ft`;
-/** What a package contains, as short lines. */
-export function contents(p: Package): string[] {
- const lines: string[] = [];
- if (p.natal) lines.push(`${p.natal} részletes képletelemzés`);
- if (p.synastry) lines.push(`${p.synastry} kapcsolati elemzés`);
- if (p.forecast) lines.push(`${p.forecast} éves előrejelzés`);
- if (p.persons) lines.push(`${p.persons} személy felvétele`);
- if (p.questions) lines.push(`${p.questions} kérdés az elemzéseidről`);
- if (p.tarot) lines.push(`${p.tarot} kártyajóslás`);
- return lines;
-}
-
/**
* Package cards with a buy button. Bigger packages show what they save and
* how little more they cost than the previous one. With Stripe the button
diff --git a/services/frontend/src/lib/packageContents.ts b/services/frontend/src/lib/packageContents.ts
new file mode 100644
index 0000000..d38fb7d
--- /dev/null
+++ b/services/frontend/src/lib/packageContents.ts
@@ -0,0 +1,13 @@
+import type { Package } from "./types";
+
+/** What a package contains, as short lines. */
+export function contents(p: Package): string[] {
+ const lines: string[] = [];
+ if (p.natal) lines.push(`${p.natal} részletes képletelemzés`);
+ if (p.synastry) lines.push(`${p.synastry} kapcsolati elemzés`);
+ if (p.forecast) lines.push(`${p.forecast} éves előrejelzés`);
+ if (p.persons) lines.push(`${p.persons} személy felvétele`);
+ if (p.questions) lines.push(`${p.questions} kérdés az elemzéseidről`);
+ if (p.tarot) lines.push(`${p.tarot} kártyajóslás`);
+ return lines;
+}
diff --git a/services/frontend/src/lib/types.ts b/services/frontend/src/lib/types.ts
index e4b326a..8b5cfa1 100644
--- a/services/frontend/src/lib/types.ts
+++ b/services/frontend/src/lib/types.ts
@@ -484,6 +484,8 @@ export type InvitationStatus = "pending" | "accepted" | "expired" | "revoked";
/** What an invitation link shows before login. */
export interface InvitationLanding {
+ /** The package that comes with it (only admins attach one). */
+ gift: Package | null;
inviter_name: string | null;
message: string | null;
status: InvitationStatus;