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,62 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
|
||||
export function ProfileForm({ displayName, locale }: { displayName: string; locale: string }) {
|
||||
const router = useRouter();
|
||||
const [name, setName] = useState(displayName);
|
||||
const [lang, setLang] = useState(locale);
|
||||
const [status, setStatus] = useState<{ ok: boolean; text: string } | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function save(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setBusy(true);
|
||||
setStatus(null);
|
||||
try {
|
||||
await api("/me", { method: "PATCH", body: { display_name: name.trim(), locale: lang } });
|
||||
setStatus({ ok: true, text: "Elmentve." });
|
||||
router.refresh();
|
||||
} catch (err) {
|
||||
setStatus({ ok: false, text: errorText(err) });
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={save} className="field" style={{ gap: 16 }}>
|
||||
<div className="field">
|
||||
<label htmlFor="display-name">Megjelenített név</label>
|
||||
<input
|
||||
id="display-name"
|
||||
className="inp"
|
||||
value={name}
|
||||
maxLength={80}
|
||||
autoComplete="name"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label htmlFor="locale">Az elemzések nyelve</label>
|
||||
<select id="locale" className="inp" value={lang} onChange={(e) => setLang(e.target.value)}>
|
||||
<option value="hu">Magyar</option>
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
Mentés
|
||||
</button>
|
||||
{status && (
|
||||
<span className={status.ok ? "msg msg-ok" : "msg msg-error"} role="status">
|
||||
{status.text}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user