From b41dc31f3eebc111adab04a7d97b6378f4ec9a2a Mon Sep 17 00:00:00 2001 From: feco Date: Sat, 21 Nov 2026 21:04:26 +0000 Subject: [PATCH] Public birth chart: keep it across pages for the tab, login for the summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL --- .../frontend/src/app/adatvedelem/page.tsx | 8 ++ services/frontend/src/app/privacy/page.tsx | 8 ++ .../frontend/src/app/profil/BirthForm.tsx | 4 +- .../app/szuletesi-horoszkop/PublicChart.tsx | 100 ++++++++++++++++-- .../frontend/src/components/SiteHeader.tsx | 1 + services/frontend/src/lib/birth.ts | 2 +- 6 files changed, 109 insertions(+), 14 deletions(-) diff --git a/services/frontend/src/app/adatvedelem/page.tsx b/services/frontend/src/app/adatvedelem/page.tsx index 54f1b7c..8352760 100644 --- a/services/frontend/src/app/adatvedelem/page.tsx +++ b/services/frontend/src/app/adatvedelem/page.tsx @@ -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 (sf_session), amely belépve tart. Reklám- vagy követő sütiket, illetve látogatottságmérőt nem használunk.

+

+ A belépés nélküli születési horoszkópnál 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. +

diff --git a/services/frontend/src/app/privacy/page.tsx b/services/frontend/src/app/privacy/page.tsx index 449445f..3d186a9 100644 --- a/services/frontend/src/app/privacy/page.tsx +++ b/services/frontend/src/app/privacy/page.tsx @@ -255,6 +255,14 @@ export default async function PrivacyPolicyPage() { We use a single cookie that is strictly necessary for the service (sf_session), which keeps you signed in. We use no advertising or tracking cookies and no analytics.

+

+ 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's own storage (not in a cookie) and are removed when you close the tab; the + page'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. +

diff --git a/services/frontend/src/app/profil/BirthForm.tsx b/services/frontend/src/app/profil/BirthForm.tsx index d9f8e96..d70f936 100644 --- a/services/frontend/src/app/profil/BirthForm.tsx +++ b/services/frontend/src/app/profil/BirthForm.tsx @@ -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 } diff --git a/services/frontend/src/app/szuletesi-horoszkop/PublicChart.tsx b/services/frontend/src/app/szuletesi-horoszkop/PublicChart.tsx index fedb401..8e79ff4 100644 --- a/services/frontend/src/app/szuletesi-horoszkop/PublicChart.tsx +++ b/services/frontend/src/app/szuletesi-horoszkop/PublicChart.tsx @@ -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 = { 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 }) {
- Mentsd el, és ingyen elemezzük + A rövid összefoglalóhoz lépj be

- 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.

- - Mentés és ingyenes összefoglaló + + Belépés és ingyenes összefoglaló
@@ -158,11 +170,67 @@ export function PublicChart() { const [ambiguity, setAmbiguity] = useState<"earlier" | "later">("earlier"); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); - const [result, setResult] = useState<{ result: Result; birth: BirthData } | null>(null); + const [result, setResult] = useState(null); + const [stored, setStored] = useState(false); const minuteRef = useRef(null); const resultRef = useRef(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() { - Ingyenes, belépés nélkül. Az adataidat nem mentjük el. + {stored && ( + + )} +

+ 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. +

{result && ( diff --git a/services/frontend/src/components/SiteHeader.tsx b/services/frontend/src/components/SiteHeader.tsx index b3e89e0..8d63d28 100644 --- a/services/frontend/src/components/SiteHeader.tsx +++ b/services/frontend/src/components/SiteHeader.tsx @@ -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" }); diff --git a/services/frontend/src/lib/birth.ts b/services/frontend/src/lib/birth.ts index 2d64294..55c29fd 100644 --- a/services/frontend/src/lib/birth.ts +++ b/services/frontend/src/lib/birth.ts @@ -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 {