Gift packages: buy a main package for someone, with a printable gift card

- /ajandek: the package, whom it is for and from whom, the recipient's
  address typed twice (or "I hand it over"), a message; paid on Stripe
  like any package, the invoice is the buyer's
- On payment the gift gets its own code (not a promo code: it cannot be
  withdrawn, and it adds the whole package); redeemed on /bevaltas
- The recipient's e-mail carries the message and the code, with the gift
  card attached as a PDF; the buyer's confirmation says it was a gift
- /ajandekaim: codes, state, the card to download, sending it by e-mail
  (again, or to another address) up to three times
- crates/gift-card draws the A4 card (example chart, questions avatar,
  QR code) as SVG and makes a PDF with krilla, fonts compiled in; the
  backend draws downloads on a blocking thread, the worker the e-mails
- Telegram notices say "(ajándék)"; unpaid gifts go after a week

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-23 20:28:11 +00:00
co-authored by Claude Opus 5.5
parent 699ce2abbd
commit c90232f40c
46 changed files with 3647 additions and 88 deletions
@@ -0,0 +1,75 @@
import type { Metadata } from "next";
import Link from "next/link";
import { payMethod } from "@/lib/payments";
import { backendGet, requireMe } from "@/lib/server";
import type { Gift, Package, PublicConfig } from "@/lib/types";
import { GiftForm } from "./GiftForm";
export const metadata: Metadata = { title: "Ajándék csomag", robots: { index: false } };
type Props = { searchParams: Promise<{ csomag?: string }> };
/** Buying a package as a gift; `?csomag=` picks the package (links on the package cards). */
export default async function GiftPage({ searchParams }: Props) {
const { csomag } = await searchParams;
const me = await requireMe(csomag ? `/ajandek?csomag=${encodeURIComponent(csomag)}` : "/ajandek");
const [catalog, config, mine] = await Promise.all([
backendGet<{ packages: Package[] }>("/v1/packages"),
backendGet<PublicConfig>("/v1/config"),
backendGet<{ gifts: Gift[] }>("/v1/gifts"),
]);
const packages = (catalog?.packages ?? []).filter((p) => p.tier === "main");
const given = mine?.gifts.length ?? 0;
return (
<main className="page" style={{ maxWidth: 1080 }}>
<div className="page-head">
<span className="eyebrow">Ajándék</span>
<h1>Ajándékozz csomagot</h1>
<p className="muted">
Születési képlet, személyre szóló elemzések, kapcsolati összevetés: ajándékba annak, akit szeretsz. Ő egy
ajándékkódot kap egy nyomtatható utalvánnyal, és a saját fiókjában váltja be.
</p>
{given > 0 && (
<p className="hint">
<Link href="/ajandekaim">Korábbi ajándékaim ({given}) →</Link>
</p>
)}
</div>
<div className="gift-layout">
<GiftForm
packages={packages}
initial={csomag}
defaultFrom={me.user.display_name ?? ""}
canPay={payMethod(config, me)}
termsConsent={config?.terms_consent === true}
/>
<aside className="gift-aside">
<figure className="gift-sample">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src="/img/ajandek-utalvany.webp"
width={420}
height={594}
alt="Minta ajándékutalvány: a csomag neve, a személyes üzenet, az ajándékkód és a QR-kód"
/>
<figcaption className="hint">Így néz ki az utalvány (A4-es PDF, nyomtatható)</figcaption>
</figure>
<section className="card gift-how" aria-labelledby="gift-how-title">
<h2 id="gift-how-title">Hogyan működik?</h2>
<ol>
<li>Kiválasztod a csomagot, és megírod, kinek szól.</li>
<li>Fizetés után elkészül az ajándékkód és az utalvány.</li>
<li>E-mailben elküldjük neki, vagy letöltöd a PDF-et, és te adod át.</li>
<li>Belép vagy regisztrál, beváltja a kódot, és a csomag az övé.</li>
</ol>
<p className="hint">A kód nem jár le, és egyszer váltható be. A számlát te kapod.</p>
</section>
</aside>
</div>
</main>
);
}