Packages: from one analysis to unlimited, admin can give them
CI / test (push) Successful in 47s
CI / build (push) Successful in 4m19s
CI / deploy (push) Skipped

A fixed catalog (packages.rs, reasoning in docs/csomagok.md): Egy elemzés
2 990 Ft, Páros 6 990 Ft, Család 11 990 Ft (featured), Korlátlan 17 990 Ft
for a year, and two top-ups. Every grant is a package_orders row; units are
credit_ledger rows with reason 'package' and never expire. The unlimited
package is a time-limited 'unlimited' entitlement: analyses use no unit and
persons have no limit, with a daily fair-use cap (UNLIMITED_DAILY_LIMIT, 5);
buying it again extends it by a year.

- GET /v1/packages, mock payment by package id, /v1/me unlimited_until
- POST /v1/admin/users/{id}/packages: give a package as a gift
- /csomagok page; the paid step of an analysis offers three packages with
  the bigger one featured; person packs use the catalog; admin user list
  has a package column
- PERSON_PACK_SIZE is replaced by the catalog's +5 személy top-up

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-17 16:19:20 +00:00
co-authored by Claude Opus 5.5
parent 0bd5c39080
commit e004ea696b
29 changed files with 1019 additions and 164 deletions
@@ -7,6 +7,7 @@ import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { PackageChooser } from "./PackageCards";
import { AnalysisView } from "./AnalysisView";
const POLL_MS = 5000;
@@ -29,6 +30,7 @@ const TEXTS = {
"Most íródik a hat fejezet a képleted alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár.",
item: "Részletes képletelemzés",
unitName: "képletelemzés",
packages: ["single", "couple", "family"],
},
synastry: {
eyebrow: "Kapcsolati elemzés",
@@ -41,6 +43,7 @@ const TEXTS = {
"Most íródik az öt fejezet a két képlet alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár.",
item: "Részletes kapcsolati elemzés",
unitName: "kapcsolati elemzés",
packages: ["addon_synastry", "couple", "family"],
},
};
@@ -54,6 +57,7 @@ export function DetailedAnalysis({
initial,
left,
isAdmin,
unlimited = false,
canPay,
note,
}: {
@@ -61,6 +65,8 @@ export function DetailedAnalysis({
initial: Analysis | null;
left: number;
isAdmin: boolean;
/** A running unlimited package: no unit is needed. */
unlimited?: boolean;
/** The stand-in payment is on (MOCK_PAYMENTS). */
canPay: boolean;
/** Shown above a finished analysis (e.g. who is the first and the second person). */
@@ -97,11 +103,10 @@ export function DetailedAnalysis({
};
}, [waiting, analysis]);
async function start(pay: boolean) {
async function start() {
setBusy(true);
setError(null);
try {
if (pay) await api("/payments/mock", { body: { unit: target.kind } });
setAnalysis(await api<Analysis>(`${path}/analyses`, { method: "POST" }));
setStep("offer");
} catch (e) {
@@ -148,17 +153,17 @@ export function DetailedAnalysis({
</p>
)}
{isAdmin ? (
{isAdmin || unlimited ? (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
<button type="button" className="btn btn-primary" onClick={start} disabled={busy}>
{busy ? "Indítás…" : `${t.item} készítése`}
</button>
<span className="hint">Adminként ingyenes.</span>
<span className="hint">{isAdmin ? "Adminként ingyenes." : "A korlátlan csomagod része."}</span>
</div>
) : left > 0 ? (
step === "confirm" ? (
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
<button type="button" className="btn btn-primary" onClick={start} disabled={busy}>
{busy ? "Indítás…" : "Igen, kérem az elemzést"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
@@ -181,19 +186,15 @@ export function DetailedAnalysis({
) : canPay ? (
step === "pay" ? (
<div className="pay-box">
<div className="pay-line">
<span>{t.item}</span>
<strong>1 db</strong>
</div>
<p className="pay-lead">
Válassz csomagot. A vásárlás után az elemzés azonnal elindul, a maradék elemzések pedig nem járnak le.
</p>
<PackageChooser ids={t.packages} canPay={canPay} onBought={start} />
<div className="form-actions">
<button type="button" className="btn btn-primary" onClick={() => start(true)} disabled={busy}>
{busy ? "Fizetés…" : "Fizetés"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
Mégse
</button>
</div>
<p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>
</div>
) : (
<div className="form-actions">