Public birth chart: keep it across pages for the tab, login for the summary
CI / test (push) Successful in 1m49s
CI / build (push) Successful in 5m52s
CI / deploy (push) Skipped

The typed birth data and the calculated chart stay in sessionStorage (no
cookie, gone with the tab), so they are back after visiting another page;
'Adatok törlése' forgets them. User-input storage for the session needs
no consent; the privacy pages say so. Signing up in the same tab fills
the profile with them.

The offer next to the chart now says the short summary needs a login.
Logged-in users get 'Csillagjegyek' in the menu.

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-21 21:04:26 +00:00
co-authored by Claude Opus 5.5
parent 985b1e872d
commit b41dc31f3e
6 changed files with 109 additions and 14 deletions
@@ -260,6 +260,14 @@ export default async function PrivacyPage() {
Csak egy, a működéshez feltétlenül szükséges sütit használunk (<code>sf_session</code>), amely belépve
tart. Reklám- vagy követő sütiket, illetve látogatottságmérőt nem használunk.
</p>
<p>
A belépés nélküli <Link href="/szuletesi-horoszkop">születési horoszkópnál</Link> a megadott születési adatokat
csak a számításhoz küldjük el, a szerveren nem tároljuk őket. Hogy oldalváltáskor ne vesszenek el, a
böngészőlap saját tárolójában maradnak (nem sütiben), és a lap bezárásakor maguktól törlődnek; az oldalon az
„Adatok törlése” gombbal előbb is törölheted őket. Ha ugyanabban a lapban regisztrálsz, a profilodban ezekkel
töltjük ki a születési adataidat. Ez a tárolás csak azt őrzi meg, amit te írtál be, ezért nem kell hozzá
külön hozzájárulás.
</p>
</section>
<section>
@@ -255,6 +255,14 @@ export default async function PrivacyPolicyPage() {
We use a single cookie that is strictly necessary for the service (<code>sf_session</code>), which keeps you
signed in. We use no advertising or tracking cookies and no analytics.
</p>
<p>
On the public birth chart page (no account needed), the birth data you enter are sent only for the
calculation and are not stored on our server. So that they are not lost when you move between pages, they
stay in the browser tab&apos;s own storage (not in a cookie) and are removed when you close the tab; the
page&apos;s “Adatok törlése” (delete data) button removes them earlier. If you sign up in the same tab, they
fill in the birth data on your profile. This storage only keeps what you typed, so it needs no separate
consent.
</p>
</section>
<section>
@@ -69,7 +69,7 @@ export function BirthForm({
if (initial || person) return;
let draft: BirthDraft | null = null;
try {
draft = JSON.parse(localStorage.getItem(BIRTH_DRAFT_KEY) ?? "null");
draft = JSON.parse(sessionStorage.getItem(BIRTH_DRAFT_KEY) ?? "null");
} catch {
return;
}
@@ -132,7 +132,7 @@ export function BirthForm({
: { label: "Saját képlet", is_primary: true, birth },
});
try {
localStorage.removeItem(BIRTH_DRAFT_KEY);
sessionStorage.removeItem(BIRTH_DRAFT_KEY);
} catch {
// storage blocked
}
@@ -1,7 +1,7 @@
"use client";
import Link from "next/link";
import { useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { CountrySelect, PlaceSearch } from "@/app/profil/BirthForm";
import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
@@ -30,6 +30,18 @@ const ERRORS: Record<string, string> = {
const GRID_LEGEND = ["conjunction", "sextile", "square", "trine", "opposition"];
/**
* The calculated chart and the typed birth data, kept for this browser tab
* only (sessionStorage: not a cookie, gone when the tab is closed), so they
* are there again after visiting another page, and the profile can offer the
* birth data after signing up in the same tab. Storage that only keeps what
* the visitor typed, for the session, needs no consent. Nothing of this is
* stored on the server.
*/
const CHART_KEY = "sf_public_chart";
type Saved = { result: Result; birth: BirthData };
/** Links to the sign pages of the Sun, Moon and Ascendant. */
function SignLinks({ result }: { result: Result }) {
const links: [string, string | null, string, boolean][] = [
@@ -101,13 +113,13 @@ function ChartView({ result, birth }: { result: Result; birth: BirthData }) {
<BigThree chart={chart} />
<SignLinks result={result} />
<div className="card calc-save">
<strong>Mentsd el, és ingyen elemezzük</strong>
<strong>A rövid összefoglalóhoz lépj be</strong>
<p className="muted" style={{ margin: 0 }}>
Regisztráció után a képleted megmarad, és ingyen kapsz hozzá egy rövid, személyre szabott összefoglalót.
Innen kérhetsz részletes elemzést, éves előrejelzést vagy kapcsolati összevetést is.
A képletedhez ingyen írunk egy rövid, személyre szabott összefoglalót, ehhez azonban be kell jelentkezned.
Belépés után a képleted is megmarad: a most megadott születési adataidat áthozzuk.
</p>
<Link href="/belepes?mod=regisztracio&vissza=/profil" className="btn btn-primary">
Mentés és ingyenes összefoglaló
<Link href="/belepes?vissza=/profil" className="btn btn-primary">
Belépés és ingyenes összefoglaló
</Link>
</div>
</div>
@@ -158,11 +170,67 @@ export function PublicChart() {
const [ambiguity, setAmbiguity] = useState<"earlier" | "later">("earlier");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [result, setResult] = useState<{ result: Result; birth: BirthData } | null>(null);
const [result, setResult] = useState<Saved | null>(null);
const [stored, setStored] = useState(false);
const minuteRef = useRef<HTMLInputElement>(null);
const resultRef = useRef<HTMLDivElement>(null);
const today = useMemo(() => new Date().toISOString().slice(0, 10), []);
// Back on the page: the birth data typed earlier and, in this tab, the chart.
useEffect(() => {
let draft: BirthDraft | null = null;
let saved: Saved | null = null;
try {
draft = JSON.parse(sessionStorage.getItem(BIRTH_DRAFT_KEY) ?? "null");
saved = JSON.parse(sessionStorage.getItem(CHART_KEY) ?? "null");
} catch {
return;
}
if (draft && /^\d{4}-\d{2}-\d{2}$/.test(draft.date) && draft.geonames_id) {
setYear(draft.date.slice(0, 4));
setMonth(String(Number(draft.date.slice(5, 7))));
setDay(String(Number(draft.date.slice(8, 10))));
setHour(draft.time ? draft.time.slice(0, 2) : "");
setMinute(draft.time ? draft.time.slice(3, 5) : "");
setTimeUnknown(!draft.time);
setCountry(draft.country);
setPlace({
geonames_id: draft.geonames_id,
name: draft.placeName,
region: draft.region,
population: null,
country_code: draft.country,
});
setStored(true);
}
if (saved?.result?.chart && saved.birth?.date) {
setResult(saved);
setStored(true);
}
}, []);
/** Forgets the birth data and the chart in this browser. */
function clear() {
try {
sessionStorage.removeItem(BIRTH_DRAFT_KEY);
sessionStorage.removeItem(CHART_KEY);
} catch {
// storage blocked
}
setYear("");
setMonth("");
setDay("");
setHour("");
setMinute("");
setTimeUnknown(false);
setCountry("HU");
setPlace(null);
setAmbiguous(false);
setResult(null);
setError(null);
setStored(false);
}
async function submit(e: React.FormEvent) {
e.preventDefault();
setError(null);
@@ -185,12 +253,14 @@ export function PublicChart() {
body: { ...birth, ...(ambiguous ? { ambiguous_time: ambiguity } : {}) },
});
setResult({ result: r, birth });
// After sign-up the profile page offers these birth data.
// Kept in this browser only: for coming back to the page, and for the profile after sign-up.
const draft: BirthDraft = { ...birth, time: birth.time ?? null, placeName: place.name, region: place.region };
try {
localStorage.setItem(BIRTH_DRAFT_KEY, JSON.stringify(draft));
sessionStorage.setItem(BIRTH_DRAFT_KEY, JSON.stringify(draft));
sessionStorage.setItem(CHART_KEY, JSON.stringify({ result: r, birth }));
setStored(true);
} catch {
// storage blocked
// storage blocked or full: the chart is still shown
}
requestAnimationFrame(() =>
resultRef.current?.scrollIntoView({
@@ -353,8 +423,16 @@ export function PublicChart() {
<button type="submit" className="btn btn-primary" disabled={busy}>
{busy ? "Számolás…" : "Elkészítem a horoszkópom"}
</button>
<span className="hint">Ingyenes, belépés nélkül. Az adataidat nem mentjük el.</span>
{stored && (
<button type="button" className="btn btn-ghost btn-sm" onClick={clear}>
Adatok törlése
</button>
)}
</div>
<p className="hint" style={{ margin: 0 }}>
Ingyenes, belépés nélkül. Az adataidat a szerveren nem tároljuk: csak ebben a böngészőlapban maradnak meg,
hogy oldalváltáskor ne vesszenek el, és a lap bezárásakor törlődnek.
</p>
</form>
{result && (
@@ -107,6 +107,7 @@ export function SiteHeader({ me }: { me: Me }) {
{ href: "/szemelyek", label: "Személyek" },
{ href: "/osszevetesek", label: "Összevetések" },
{ href: "/kartyajoslas", label: "Kártyajóslás" },
{ href: "/csillagjegyek", label: "Csillagjegyek" },
{ href: "/csomagok", label: "Csomagok" },
];
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
+1 -1
View File
@@ -38,7 +38,7 @@ export function composeTime(hour: string, minute: string): string | null {
return h <= 23 && m <= 59 ? `${pad(h)}:${pad(m)}` : null;
}
/** Birth data typed into the public chart page, offered on the profile after sign-up. */
/** Birth data typed into the public chart page (sessionStorage), offered on the profile after sign-up in the same tab. */
export const BIRTH_DRAFT_KEY = "sf_birth_draft";
export interface BirthDraft {