Backend: - own birth data: three corrections within an hour of the first save, then one change per 24 hours (birth_data_changes); 429 birth_data_change_limit with the user-facing message; /v1/me birth_change shows the notice; admins are not limited - admins get detailed analyses free (no unit spent) - POST /v1/payments/mock (MOCK_PAYMENTS): stand-in payment that adds a unit, until Stripe is connected; on in the compose files for now Frontend: - detailed analysis offer: admin starts it free, users with units confirm, others go through the (stand-in) payment step - turning wheel with elapsed time while the summary or the analysis is being written - no "adatok javítása" on the chart page (only in the profile), limit notice there; wheel hover highlighting removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
82 lines
2.9 KiB
TypeScript
82 lines
2.9 KiB
TypeScript
import type { Metadata } from "next";
|
||
|
||
import { ROLE_LABELS, formatDate } from "@/lib/astro";
|
||
import { backendGet, requireMe } from "@/lib/server";
|
||
import type { Chart } from "@/lib/types";
|
||
|
||
import { BirthEditor } from "./BirthEditor";
|
||
import { ProfileForm } from "./ProfileForm";
|
||
|
||
export const metadata: Metadata = { title: "Profil" };
|
||
|
||
const PROVIDERS: Record<string, string> = { google: "Google", password: "E-mail és jelszó" };
|
||
|
||
export default async function ProfilePage() {
|
||
const me = await requireMe("/profil");
|
||
const chart = me.primary_chart_id ? await backendGet<Chart>(`/v1/charts/${me.primary_chart_id}`) : null;
|
||
const { user } = me;
|
||
|
||
return (
|
||
<main className="page">
|
||
<div className="page-head">
|
||
<h1>Profil</h1>
|
||
<p className="muted">A fiókod és a születési adataid.</p>
|
||
</div>
|
||
|
||
<section className="card" aria-labelledby="account">
|
||
<div className="card-head">
|
||
<h2 id="account">Fiók</h2>
|
||
<div className="row" style={{ gap: 6 }}>
|
||
{user.roles.map((r) => (
|
||
<span key={r} className={r === "user" ? "badge" : "badge badge-gold"}>
|
||
{ROLE_LABELS[r] ?? r}
|
||
</span>
|
||
))}
|
||
</div>
|
||
</div>
|
||
<div className="grid-2">
|
||
<dl className="facts">
|
||
<dt>E-mail</dt>
|
||
<dd>
|
||
{user.email} {user.email_verified && <span className="badge">megerősítve</span>}
|
||
</dd>
|
||
<dt>Belépés</dt>
|
||
<dd>{me.providers.map((p) => PROVIDERS[p] ?? p).join(", ") || "–"}</dd>
|
||
<dt>Részletes elemzések</dt>
|
||
<dd>
|
||
{me.analyses_left.natal} képlet, {me.analyses_left.synastry} szinasztria
|
||
</dd>
|
||
<dt>Tag óta</dt>
|
||
<dd>{formatDate(user.created_at)}</dd>
|
||
</dl>
|
||
<ProfileForm displayName={user.display_name ?? ""} locale={user.locale} />
|
||
</div>
|
||
</section>
|
||
|
||
<section className="card" aria-labelledby="birth">
|
||
<div className="card-head">
|
||
<h2 id="birth">Születési adataim</h2>
|
||
{chart && !chart.highlights.time_known && <span className="badge">ismeretlen születési idő</span>}
|
||
</div>
|
||
<BirthEditor
|
||
chart={
|
||
chart
|
||
? {
|
||
birth: chart.birth_data,
|
||
placeName: chart.chart.location.place?.name ?? null,
|
||
region: chart.chart.location.place?.region ?? null,
|
||
countryCode: chart.chart.location.place?.country_code ?? chart.birth_data.country ?? null,
|
||
zone: chart.chart.time.zone,
|
||
utcOffset: chart.chart.time.utc_offset,
|
||
dst: chart.chart.time.dst,
|
||
}
|
||
: null
|
||
}
|
||
chartId={chart?.id ?? null}
|
||
notice={me.birth_change.notice}
|
||
/>
|
||
</section>
|
||
</main>
|
||
);
|
||
}
|