Start the Next.js frontend: Google login, profile, birth data, admin
services/frontend (Next.js 16, App Router) runs on port 3001 in compose. The browser only talks to the frontend: /api/v1/* is proxied to the backend, so the session cookie lives on the frontend's host, and /api/geo/* exposes the country list and place search of the horoscope-api. - /belepes: Google Identity Services button, client id from /v1/config - /profil: account facts, display name and language, own birth data with place search, DST ambiguity prompt and the chart's positions - /admin: user search, role toggles, credit grants (admins only, 404 otherwise) Services now tolerate migrations newer than their binary, so they can be rebuilt one at a time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
import { ChartTables } from "@/components/ChartTables";
|
||||
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 adatai és a saját születési képleted.</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>Kreditek</dt>
|
||||
<dd>{me.credits}</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
|
||||
}
|
||||
>
|
||||
{chart && <ChartTables chart={chart} />}
|
||||
</BirthEditor>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user