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
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
import type { Metadata } from "next";
|
|
import Link from "next/link";
|
|
|
|
import { ChartCard } from "@/components/ChartCard";
|
|
import { PersonActions } from "@/components/PersonActions";
|
|
import { PersonPacks } from "@/components/PersonPacks";
|
|
import { backendGet, requireMe } from "@/lib/server";
|
|
import type { ChartListItem, PublicConfig } from "@/lib/types";
|
|
|
|
export const metadata: Metadata = { title: "Személyek" };
|
|
|
|
/** The persons the user added, with room for a new one. */
|
|
export default async function PersonsPage() {
|
|
const me = await requireMe("/szemelyek");
|
|
const [list, config] = await Promise.all([
|
|
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
|
|
backendGet<PublicConfig>("/v1/config"),
|
|
]);
|
|
const charts = list?.charts ?? [];
|
|
const persons = charts.filter((c) => c.kind === "person");
|
|
const ownId = charts.find((c) => c.is_primary)?.id ?? null;
|
|
const isAdmin = me.user.roles.includes("admin");
|
|
const slots = me.persons;
|
|
const full = slots.left === 0;
|
|
const now = Date.now();
|
|
|
|
return (
|
|
<main className="page" style={{ maxWidth: 1080 }}>
|
|
<div className="page-head">
|
|
<h1>Személyek</h1>
|
|
<p className="muted">
|
|
Társad, családtagjaid, barátaid képlete. Mindegyikhez kérhetsz részletes elemzést, összevetheted a sajátoddal,
|
|
és a képletoldal címére kattintva válthatsz köztük.
|
|
</p>
|
|
</div>
|
|
|
|
<div className="chart-cards">
|
|
{persons.map((p) => (
|
|
<ChartCard key={p.id} chart={p} title={p.label}>
|
|
<PersonActions
|
|
id={p.id}
|
|
name={p.label}
|
|
ownId={ownId}
|
|
editable={isAdmin || (p.editable_until !== null && Date.parse(p.editable_until) > now)}
|
|
/>
|
|
</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>
|
|
)}
|
|
</div>
|
|
|
|
{!slots.unlimited && (
|
|
<section className="card" aria-labelledby="slots-title">
|
|
<div className="card-head">
|
|
<h2 id="slots-title">Személyek</h2>
|
|
<span className="badge">
|
|
{slots.used} / {slots.limit} hely
|
|
</span>
|
|
</div>
|
|
<p className="muted">
|
|
{full
|
|
? "Elfogytak a helyeid. Újabb személyhez válassz csomagot."
|
|
: "A felvett személyek képletét és elemzéseit itt éred el. Egy törölt személy helye nem szabadul fel."}
|
|
</p>
|
|
<PersonPacks canPay={config?.mock_payments ?? false} />
|
|
</section>
|
|
)}
|
|
</main>
|
|
);
|
|
}
|