Weekly horoscope: its own page, a Monday e-mail, and one page for every e-mail setting
CI / test (push) Successful in 3m17s
CI / build (push) Skipped
CI / deploy (push) Skipped

- The week's sky on the member's own chart (horoscope-api POST /v1/week,
  astro_engine::week): the planets' aspects to the natal points with the day
  each is exact, positions, the Moon's signs, lunar phases, stations and sign
  changes; stored once per chart and week (weekly_skies, migration 0047).
- Its text is a 'weekly' analysis written by the summary's (cheap) model when
  the member opens /heti-horoszkop: one month per page, the newest week
  first, the waiting animation while it is written. In the menu, and linked
  from the chart page.
- Monday 7:00 e-mail (worker task 'weekly'): only that it is there; on by
  default for everyone with a chart, members of today too. Its footer opens
  /ertesitesek?token=…, where the weekly e-mail and every forum e-mail can
  be set without logging in; the mail client's one-click unsubscribe turns
  off the weekly one. Also a switch on the page and on the Profile page.
- Privacy notice (HU/EN) describes it; ratings, admin labels and the model
  page know the new kind.

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-27 09:40:09 +00:00
co-authored by Claude Opus 5.5
parent 50c29e4595
commit 0358e137f1
46 changed files with 2368 additions and 70 deletions
+18 -5
View File
@@ -207,6 +207,17 @@ export default async function PrivacyPage() {
<td>Biztonság, hibakeresés, visszaélések kiszűrése</td>
<td>Jogos érdek (6. cikk (1) f)</td>
</tr>
<tr>
<td>
Heti horoszkóp: a hét égboltja a saját képleteden, a belőle írt szöveg, és hogy kéred-e a hétfői
értesítő levelet
</td>
<td>
Az ingyenes heti horoszkóp; hétfőnként egy rövid levél, hogy itt az új (alapból küldjük, a levél
alján, a Heti horoszkóp oldalon vagy a Profil oldalon bármikor kikapcsolhatod)
</td>
<td>Szerződés teljesítése; a levélnél jogos érdek (6. cikk (1) f)</td>
</tr>
<tr>
<td>
Melyik oldalt nyitottad meg, honnan érkeztél, a böngésződ és az eszközöd típusa, az országod és az oldal
@@ -271,7 +282,8 @@ export default async function PrivacyPage() {
<p>
<strong>Mire használjuk:</strong> a fiókod létrehozására és arra, hogy belépéskor felismerjünk; az
e-mail-címedet a rendszerlevelekhez (például ha elkészült egy elemzésed, elfogadták a meghívódat, vagy
válasz érkezett vagy megemlítettek a fórumon, illetve a fórum heti összefoglalója, ha ezeket kérted); a
válasz érkezett vagy megemlítettek a fórumon, illetve a fórum heti összefoglalója, ha ezeket kérted) és a
heti horoszkóp hétfői értesítőjéhez (ha nem kapcsoltad ki); a
nevedet a megjelenítéshez; a nyelvet az oldal és az elemzések nyelvéhez.
</p>
<p>
@@ -312,10 +324,11 @@ export default async function PrivacyPage() {
<section>
<h2>4. Az elemzések és a mesterséges intelligencia</h2>
<p>
A rövid összefoglalót, a részletes elemzéseket, a kártyajóslást és a kérdésekre adott válaszokat nagy nyelvi
modell (mesterséges intelligencia) írja. A modellhez a <strong>képlet csillagászati adatai</strong> jutnak
el (a bolygók jegye, foka, háza és fényszögei), kártyajóslásnál a kihúzott lapok, és ha kérdést teszel fel,
a kérdésed szövege. Nevet, e-mail-címet, születési dátumot, időpontot vagy helyet nem küldünk el. Kérjük, a
A rövid összefoglalót, a heti horoszkópot, a részletes elemzéseket, a kártyajóslást és a kérdésekre adott
válaszokat nagy nyelvi modell (mesterséges intelligencia) írja. A modellhez a{" "}
<strong>képlet csillagászati adatai</strong> jutnak el (a bolygók jegye, foka, háza és fényszögei), a heti
horoszkópnál a hét égboltja is (hol járnak a bolygók, és milyen fényszöget alkotnak a képleteddel),
kártyajóslásnál a kihúzott lapok, és ha kérdést teszel fel, a kérdésed szövege. Nevet, e-mail-címet, születési dátumot, időpontot vagy helyet nem küldünk el. Kérjük, a
kérdéseidbe se írj neveket vagy érzékeny adatot (például egészségügyi adatot). Az elemzés szórakoztató és
önismereti célú szöveg, nem minősül egészségügyi, pénzügyi, jogi vagy más szakmai tanácsnak.
</p>
@@ -12,6 +12,7 @@ const PAGE = 50;
const SOURCES: Record<string, string> = { analysis: "Elemzés", question: "Kérdés-válasz", preview: "Prompt-próba" };
const KINDS: Record<string, string> = {
summary: "összefoglaló",
weekly: "heti horoszkóp",
natal: "képletelemzés",
synastry: "kapcsolati",
forecast: "előrejelzés",
@@ -9,7 +9,11 @@ import type { CatalogModel, ModelFunction } from "@/lib/types";
import { RunningJobs } from "./RunningJobs";
const LABELS: Record<ModelFunction["kind"], { title: string; about: string }> = {
summary: { title: "Tömör összefoglaló", about: "Ingyenes, minden új képlethez magától elkészül. Olcsó, gyors modell elég." },
summary: {
title: "Tömör összefoglaló és heti horoszkóp",
about:
"Ingyenes: az összefoglaló minden új képlethez magától elkészül, a heti horoszkóp akkor, amikor a tag a héten megnyitja a képletét. Olcsó, gyors modell elég.",
},
analysis: {
title: "Elemzések és éves előrejelzés",
about: "Fizetős szövegek: részletes képletelemzés, kapcsolati elemzés és éves előrejelzés.",
@@ -7,6 +7,7 @@ import type { AdminJob } from "@/lib/types";
const KINDS: Record<AdminJob["kind"], string> = {
summary: "Összefoglaló",
weekly: "Heti horoszkóp",
natal: "Képletelemzés",
synastry: "Kapcsolati elemzés",
forecast: "Éves előrejelzés",
@@ -0,0 +1,214 @@
"use client";
import { useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
interface ForumMail {
replies: "off" | "daily" | "instant";
followed: "off" | "daily";
messages: "off" | "instant";
mentions: "off" | "instant";
/** Only for volunteer listeners. */
listener: "off" | "instant" | null;
weekly: boolean;
}
interface Settings {
weekly_horoscope: boolean;
forum: ForumMail | null;
}
/** Everything off: the weekly horoscope and every forum e-mail. */
function allOff(s: Settings): Settings {
return {
weekly_horoscope: false,
forum: s.forum
? {
replies: "off",
followed: "off",
messages: "off",
mentions: "off",
listener: s.forum.listener === null ? null : "off",
weekly: false,
}
: null,
};
}
/**
* The e-mail settings behind an e-mail's footer link: the token in the link
* stands for the login. Nothing changes until a button is pressed (mail
* providers' link scanners open every link).
*/
export function MailSettings({ token }: { token: string | null }) {
const [settings, setSettings] = useState<Settings | null>(null);
const [loadError, setLoadError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [saved, setSaved] = useState<string | null>(null);
const query = token ? `?token=${encodeURIComponent(token)}` : "";
useEffect(() => {
if (!token) return;
api<Settings>(`/public/notifications${query}`)
.then(setSettings)
.catch((e) => setLoadError(errorText(e)));
}, [token, query]);
if (!token) {
return (
<p className="msg msg-error" role="alert">
Hiányzik a link vége. Nyisd meg a teljes linket a levélből.
</p>
);
}
if (loadError) {
return (
<p className="msg msg-error" role="alert">
Ez a link nem érvényes. Nyisd meg a teljes linket a levélből, vagy lépj be, és a Profil oldalon állítsd be.
</p>
);
}
if (!settings) {
return <p className="muted">Betöltés…</p>;
}
async function save(next: Settings, done: string) {
setBusy(true);
setError(null);
setSaved(null);
try {
setSettings(await api<Settings>(`/public/notifications${query}`, { method: "PUT", body: next }));
setSaved(done);
} catch (e) {
setError(errorText(e));
} finally {
setBusy(false);
}
}
const forum = settings.forum;
const setForum = (patch: Partial<ForumMail>) => {
setSaved(null);
setSettings({ ...settings, forum: forum ? { ...forum, ...patch } : null });
};
return (
<div className="card field mail-settings" style={{ gap: 18 }}>
<fieldset className="mail-set">
<legend>Heti horoszkóp</legend>
<label className="check">
<input
type="checkbox"
checked={settings.weekly_horoscope}
onChange={(e) => {
setSaved(null);
setSettings({ ...settings, weekly_horoscope: e.target.checked });
}}
/>
<span>Hétfőnként szóljatok, ha itt az új heti horoszkópom</span>
</label>
</fieldset>
{forum && (
<fieldset className="mail-set">
<legend>Fórum</legend>
<label htmlFor="mail-replies">Ha valaki válaszol nekem (a szálamban vagy a hozzászólásomra)</label>
<select
id="mail-replies"
className="inp"
value={forum.replies}
onChange={(e) => setForum({ replies: e.target.value as ForumMail["replies"] })}
>
<option value="daily">Napi összesítőben, este</option>
<option value="instant">Azonnal (szálanként óránként legfeljebb egy levél)</option>
<option value="off">Ne küldjetek</option>
</select>
<label htmlFor="mail-followed">Új hozzászólás a követett szálaimban</label>
<select
id="mail-followed"
className="inp"
value={forum.followed}
onChange={(e) => setForum({ followed: e.target.value as ForumMail["followed"] })}
>
<option value="off">Ne küldjetek</option>
<option value="daily">Napi összesítőben, este</option>
</select>
<label htmlFor="mail-messages">Privát üzenet vagy beszélgetési kérés</label>
<select
id="mail-messages"
className="inp"
value={forum.messages}
onChange={(e) => setForum({ messages: e.target.value as ForumMail["messages"] })}
>
<option value="instant">Azonnal</option>
<option value="off">Ne küldjetek</option>
</select>
<label htmlFor="mail-mentions">Ha valaki megemlít</label>
<select
id="mail-mentions"
className="inp"
value={forum.mentions}
onChange={(e) => setForum({ mentions: e.target.value as ForumMail["mentions"] })}
>
<option value="instant">Azonnal</option>
<option value="off">Ne küldjetek</option>
</select>
{forum.listener !== null && (
<>
<label htmlFor="mail-listener">
Kísérőként: ha egy meghallgatást kérő szál két órája válasz nélkül vár
</label>
<select
id="mail-listener"
className="inp"
value={forum.listener}
onChange={(e) => setForum({ listener: e.target.value as "off" | "instant" })}
>
<option value="off">Ne küldjetek</option>
<option value="instant">Azonnal (hat óránként legfeljebb egy levél)</option>
</select>
</>
)}
<label className="check">
<input type="checkbox" checked={forum.weekly} onChange={(e) => setForum({ weekly: e.target.checked })} />
<span>Heti összefoglaló vasárnap este: a hét legélénkebb szálai</span>
</label>
</fieldset>
)}
<div className="row" style={{ gap: 10, flexWrap: "wrap" }}>
<button
type="button"
className="btn btn-primary"
disabled={busy}
onClick={() => void save(settings, "Elmentettük a beállításaidat.")}
>
{busy ? "Mentés…" : "Mentés"}
</button>
<button
type="button"
className="btn"
disabled={busy}
onClick={() => void save(allOff(settings), "Leiratkoztál: ezekről nem küldünk több levelet.")}
>
Mindenről leiratkozom
</button>
</div>
{saved && (
<p className="msg msg-ok" role="status">
{saved}
</p>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<p className="hint" style={{ margin: 0 }}>
A jelszóval, a vásárlással és a számlával kapcsolatos leveleket ettől függetlenül megkapod.
</p>
</div>
);
}
@@ -0,0 +1,24 @@
import type { Metadata } from "next";
import { MailSettings } from "./MailSettings";
export const metadata: Metadata = { title: "Értesítések", robots: { index: false } };
/** Every e-mail setting, from the link in an e-mail's footer (no login needed). */
export default async function MailSettingsPage({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[]>>;
}) {
const raw = (await searchParams).token;
const token = Array.isArray(raw) ? raw[0] : raw;
return (
<main className="page" style={{ maxWidth: 640 }}>
<div className="page-head">
<h1>Értesítések</h1>
<p className="muted">Itt állíthatod be, miről kérsz levelet a Sorsfonalaktól.</p>
</div>
<MailSettings token={token ?? null} />
</main>
);
}
+23 -2
View File
@@ -1407,7 +1407,7 @@ span.tarot-fan-card { cursor: default; }
}
/* The ☰ menu: instead of the header's link rows where they no longer fit
on one line (logged out below 1240px; logged in below 1380px, with more
on one line (logged out below 1240px; logged in below 1520px, with more
links and the package). */
.mobile-menu { display: none; margin-left: auto; }
.mobile-menu-button {
@@ -1436,7 +1436,7 @@ span.tarot-fan-card { cursor: default; }
@media (max-width: 1500px) {
.site-header .pkg-pill-detail { display: none; }
}
@media (max-width: 1380px) {
@media (max-width: 1520px) {
.mobile-menu-app { display: block; }
.site-header .app-nav { display: none; }
.site-header .who { margin-left: auto; }
@@ -1858,3 +1858,24 @@ span.tarot-fan-card { cursor: default; }
}
.inapp-note p { margin: 0; color: var(--ink-2); }
.inapp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
/* The weekly horoscope page (one month at a time) and its link on the chart page. */
.weekly-card { gap: 10px; }
.weekly-text p { margin: 0 0 10px; }
.weekly-text p:last-child { margin-bottom: 0; }
.weekly-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.weekly-pager > :first-child { justify-self: start; }
.weekly-pager > :last-child { justify-self: end; }
.weekly-pager strong { font-family: var(--font-display); font-size: 22px; font-weight: 600; text-align: center; }
.weekly-teaser { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink-2); border-color: rgba(217, 180, 106, 0.35); }
.weekly-teaser:hover { border-color: var(--gold); }
.weekly-teaser-more { color: var(--gold); font-weight: 500; }
@media (max-width: 480px) {
.weekly-pager { grid-template-columns: 1fr 1fr; }
.weekly-pager strong { grid-column: 1 / -1; grid-row: 1; }
}
/* The e-mail settings behind an e-mail's footer link. */
.mail-set { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mail-set legend { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.mail-set label:not(.check) { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
@@ -0,0 +1,151 @@
"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import { MONTHS, WeekCard, WeeklyEmailSwitch } from "@/components/WeeklyHoroscope";
import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
const POLL_MS = 3000;
const MAX_POLLS = 60;
interface Week {
week_start: string;
week_end: string;
analysis: Analysis;
}
interface Month {
month: string;
current_month: string;
this_week: string;
weeks: Week[];
older: string | null;
newer: string | null;
email: boolean;
}
/** "2026. november". */
function monthName(key: string): string {
const [y, m] = key.split("-").map(Number);
return `${y}. ${MONTHS[m - 1]}`;
}
/**
* One month of weekly horoscopes, the newest week first. In this month the
* week's horoscope is asked for first (queued if new), and polled until the
* worker has written it; meanwhile its card shows the waiting animation.
*/
export function WeeklyPage({ month, isAdmin }: { month: string | null; isAdmin: boolean }) {
const [data, setData] = useState<Month | null>(null);
const [error, setError] = useState<string | null>(null);
const [gaveUp, setGaveUp] = useState(false);
// Bumped when an admin has this week's text written again: polls anew.
const [round, setRound] = useState(0);
const query = month ? `?month=${month}` : "";
/** This week's horoscope into the list (it may not be there yet). */
const putWeek = (week: Week) =>
setData((d) => (d ? { ...d, weeks: [week, ...d.weeks.filter((w) => w.week_start !== week.week_start)] } : d));
useEffect(() => {
let stopped = false;
let timer: ReturnType<typeof setTimeout> | undefined;
let polls = 0;
const poll = async () => {
try {
const week = await api<Week & { email: boolean }>("/weekly", { method: "POST" });
if (stopped) return;
putWeek({ week_start: week.week_start, week_end: week.week_end, analysis: week.analysis });
if (week.analysis.status === "done") return;
} catch {
// try again on the next tick
}
if (++polls >= MAX_POLLS) return setGaveUp(true);
timer = setTimeout(poll, POLL_MS);
};
(async () => {
try {
const page = await api<Month>(`/weekly/history${query}`);
if (stopped) return;
setData(page);
if (page.month === page.current_month) await poll();
} catch (e) {
if (!stopped) setError(errorText(e));
}
})();
return () => {
stopped = true;
clearTimeout(timer);
};
}, [query, round]);
if (error) {
return (
<p className="msg msg-error" role="alert">
{error}
</p>
);
}
if (!data) {
return <p className="muted">Betöltés…</p>;
}
const restarted = (week: Week) => (a: Analysis) => {
setGaveUp(false);
setData((d) =>
d ? { ...d, weeks: d.weeks.map((w) => (w.week_start === week.week_start ? { ...w, analysis: a } : w)) } : d,
);
if (week.week_start === data.this_week) setRound((r) => r + 1);
};
const pager = (
<nav className="weekly-pager" aria-label="Hónapok">
{data.older ? (
<Link href={`/heti-horoszkop?honap=${data.older}`} className="btn btn-sm">
← Korábbi hónap
</Link>
) : (
<span />
)}
<strong>{monthName(data.month)}</strong>
{data.newer ? (
<Link
href={data.newer === data.current_month ? "/heti-horoszkop" : `/heti-horoszkop?honap=${data.newer}`}
className="btn btn-sm"
>
Újabb hónap →
</Link>
) : (
<span />
)}
</nav>
);
return (
<div className="field" style={{ gap: 18 }}>
{pager}
{data.weeks.length === 0 ? (
<p className="muted">Ebben a hónapban nem nézted meg a heti horoszkópodat.</p>
) : (
data.weeks.map((w) => (
<WeekCard
key={w.week_start}
start={w.week_start}
end={w.week_end}
analysis={w.analysis}
current={w.week_start === data.this_week}
gaveUp={w.week_start === data.this_week && gaveUp}
isAdmin={isAdmin}
onRestarted={restarted(w)}
/>
))
)}
{(data.older || data.newer) && data.weeks.length > 1 && pager}
<div className="card">
<WeeklyEmailSwitch initial={data.email} label="Hétfőnként szóljatok e-mailben, ha itt az új heti horoszkópom" />
</div>
</div>
);
}
@@ -0,0 +1,46 @@
import type { Metadata } from "next";
import Link from "next/link";
import { requireMe } from "@/lib/server";
import { WeeklyPage } from "./WeeklyPage";
export const metadata: Metadata = { title: "Heti horoszkóp" };
/**
* The member's weekly horoscopes, one month at a time, the newest first
* (`?honap=2026-11` pages back). This week's is written when the page opens.
*/
export default async function WeeklyHoroscopePage({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[]>>;
}) {
const me = await requireMe("/heti-horoszkop");
const raw = (await searchParams).honap;
const month = (Array.isArray(raw) ? raw[0] : raw) ?? null;
return (
<main className="page" style={{ maxWidth: 760 }}>
<div className="page-head">
<h1>Heti horoszkóp</h1>
<p className="muted">Hétfőnként új, a saját képletedből és a hét égboltjából.</p>
</div>
{me.primary_chart_id ? (
<WeeklyPage
key={month ?? "now"}
month={month && /^\d{4}-\d{2}$/.test(month) ? month : null}
isAdmin={me.user.roles.includes("admin")}
/>
) : (
<div className="card field" style={{ gap: 12 }}>
<p style={{ margin: 0 }}>A heti horoszkóphoz előbb add meg a születési adataidat.</p>
<div>
<Link href="/profil#birth" className="btn btn-primary">
Születési adatok megadása
</Link>
</div>
</div>
)}
</main>
);
}
@@ -87,6 +87,15 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
referralOpen={config?.referral_rewards ?? false}
referralsLeft={me.referral_rewards.limit - me.referral_rewards.earned}
/>
{chart.id === me.primary_chart_id && (
<Link href="/heti-horoszkop" className="card weekly-teaser">
<span className="eyebrow">Heti horoszkóp</span>
<span>Hétfőnként új, a saját képletedből és a hét égboltjából.</span>
<span className="weekly-teaser-more">
Elolvasom a heti horoszkópomat<span aria-hidden="true"> →</span>
</span>
</Link>
)}
<BigThree chart={chart} />
{forumEnabled() && (
<div className="card ask-forum-card">
+11 -4
View File
@@ -124,6 +124,11 @@ const DATA: [string, string, string][] = [
"Security, troubleshooting, preventing abuse",
"Legitimate interest (Art. 6(1)(f))",
],
[
"Weekly horoscope: the week's sky on your own chart, the text written from it, and whether you want the Monday notice e-mail",
"The free weekly horoscope; a short e-mail on Mondays that the new one is there (sent by default; turn it off at any time in the e-mail's footer, on the Weekly horoscope page or on your Profile page)",
"Performance of the contract; for the e-mail, legitimate interest (Art. 6(1)(f))",
],
[
"Which page you opened, where you came from, your browser and device type, your country and how long the page took to load (visitor statistics)",
"Seeing how many people view each page and whether the site is fast enough",
@@ -234,7 +239,8 @@ export default async function PrivacyPolicyPage() {
<p>
<strong>How we use it:</strong> to create your account and recognise you when you sign in; your e-mail address
for service e-mails (for example when a reading is ready, an invitation was accepted, or someone replied on the
forum, when someone mentions you there, or the forum's weekly summary, if you asked for these); your name for
forum, when someone mentions you there, or the forum's weekly summary, if you asked for these) and for the
weekly horoscope's Monday notice (unless you turned it off); your name for
display;
your language for the language of the site and your readings.
</p>
@@ -276,10 +282,11 @@ export default async function PrivacyPolicyPage() {
<section>
<h2>4. Readings and artificial intelligence</h2>
<p>
The short summary, the detailed readings, tarot readings and the answers to your questions are written by a
large language model (artificial intelligence). The model receives the{" "}
The short summary, the weekly horoscope, the detailed readings, tarot readings and the answers to your
questions are written by a large language model (artificial intelligence). The model receives the{" "}
<strong>astronomical data of the chart</strong> (the signs, degrees, houses and aspects of the planets), for
a tarot reading the cards drawn, and when you ask a question, its text. We never send your name, e-mail
the weekly horoscope also the week's sky (where the planets are and the aspects they make to your chart),
for a tarot reading the cards drawn, and when you ask a question, its text. We never send your name, e-mail
address, birth date, time or place. Please do not write names or sensitive data (such as health data) into
your questions either. The readings are for entertainment and self-reflection and are not medical,
financial, legal or other professional advice.
+13
View File
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import Link from "next/link";
import { ROLE_LABELS, formatDate } from "@/lib/astro";
import { WeeklyEmailSwitch } from "@/components/WeeklyHoroscope";
import { backendGet, requireMe } from "@/lib/server";
import type { Chart } from "@/lib/types";
@@ -84,6 +85,18 @@ export default async function ProfilePage() {
/>
</section>
<section className="card" aria-labelledby="levelek-title" id="levelek">
<h2 id="levelek-title">Levelek</h2>
<WeeklyEmailSwitch
initial={me.weekly_email}
label="Heti horoszkóp: hétfőnként szólunk e-mailben, ha itt az új"
/>
<p className="hint" style={{ margin: 0 }}>
A levélben csak annyi áll, hogy elkészült; a horoszkópot belépés után a Heti horoszkóp oldalon olvashatod.
{!chart && " Ehhez előbb add meg a születési adataidat."}
</p>
</section>
<section className="card" aria-labelledby="adataim">
<h2 id="adataim">Adataim</h2>
<p className="muted">
@@ -3,6 +3,7 @@
export type NavIconName =
| "chart"
| "weekly"
| "persons"
| "compare"
| "tarot"
@@ -45,6 +46,13 @@ export function NavIcon({ name }: { name: NavIconName }) {
/>
</>
)}
{name === "weekly" && (
<>
<rect x="4" y="5" width="16" height="15" rx="2.2" />
<path d="M4 9.5h16M8.5 3v4M15.5 3v4" />
<path d="M12 12l.9 2 2.1.9-2.1.9-.9 2-.9-2-2.1-.9 2.1-.9z" className="nav-icon-fill" />
</>
)}
{name === "famous" && (
<path d="M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6L12 16.6 6.6 19.5l1.2-6L3.3 9.3l6.1-.7z" />
)}
@@ -148,11 +148,12 @@ const EXPLORE: NavItem[] = [
/**
* The header of the logged-in app: the menu with gold marks (the free pages
* in one "Felfedezés" dropdown), the Moon today, the package and the account.
* Below 1380px the menu moves behind ☰, grouped.
* Below 1520px the menu moves behind ☰, grouped.
*/
export function SiteHeader({ me, sky }: { me: Me; sky?: SkyNow | null }) {
const own: NavItem[] = [
{ href: "/keplet", label: "Képletem", icon: "chart" },
{ href: "/heti-horoszkop", label: "Heti horoszkóp", icon: "weekly" },
{ href: "/szemelyek", label: "Személyek", icon: "persons" },
{ href: "/osszevetesek", label: "Összevetések", icon: "compare" },
{ href: "/kartyajoslas", label: "Kártyajóslás", icon: "tarot" },
@@ -0,0 +1,155 @@
"use client";
import { useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { RateContent } from "./RateContent";
import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { Paragraphs } from "./Rich";
export const MONTHS = [
"január",
"február",
"március",
"április",
"május",
"június",
"július",
"augusztus",
"szeptember",
"október",
"november",
"december",
];
/** "november 30. – december 6." or "december 7–13.". */
export function weekRange(start: string, end: string): string {
const [, m1, d1] = start.split("-").map(Number);
const [, m2, d2] = end.split("-").map(Number);
return m1 === m2 ? `${MONTHS[m1 - 1]} ${d1}–${d2}.` : `${MONTHS[m1 - 1]} ${d1}. – ${MONTHS[m2 - 1]} ${d2}.`;
}
/**
* Monday's e-mail about the weekly horoscope, on or off. Turned on, the first
* one comes next Monday.
*/
export function WeeklyEmailSwitch({ initial, label }: { initial: boolean; label: string }) {
const [on, setOn] = useState(initial);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
useEffect(() => setOn(initial), [initial]);
async function toggle(next: boolean) {
setBusy(true);
setError(null);
setOn(next);
try {
await api("/weekly/email", { method: "PUT", body: { on: next } });
} catch (e) {
setOn(!next);
setError(errorText(e));
} finally {
setBusy(false);
}
}
return (
<div className="weekly-email">
<label className="check">
<input type="checkbox" checked={on} disabled={busy} onChange={(e) => void toggle(e.target.checked)} />
<span>{label}</span>
</label>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
);
}
/**
* One week's horoscope: the text, or while the worker writes it the waiting
* animation (this week's, the page polls it), or a note when it failed.
*/
export function WeekCard({
start,
end,
analysis,
current = false,
gaveUp = false,
isAdmin = false,
onRestarted,
}: {
start: string;
end: string;
analysis: Analysis | null;
/** This week: marked, and it may still be written. */
current?: boolean;
/** The page stopped waiting for it. */
gaveUp?: boolean;
isAdmin?: boolean;
onRestarted?: (a: Analysis) => void;
}) {
const content = analysis?.status === "done" ? analysis.content : null;
const titleId = `week-${start}`;
return (
<article
className={current ? "card summary-card weekly-card weekly-current" : "card weekly-card"}
aria-labelledby={titleId}
aria-busy={!content && !gaveUp && analysis?.status !== "failed"}
>
<span className="eyebrow">
{weekRange(start, end)}
{current && " · ez a hét"}
</span>
{content ? (
<>
{isAdmin && analysis && onRestarted && (
<RegenerateButton<Analysis> url={`/admin/analyses/${analysis.id}/regenerate`} onStarted={onRestarted} />
)}
<h2 id={titleId} className="summary-title">
{content.title}
</h2>
<div className="summary-text weekly-text" lang={analysis?.language}>
<Paragraphs text={content.text ?? ""} />
</div>
{analysis && <RateContent analysisId={analysis.id} />}
</>
) : (
<>
<h2 id={titleId} className="sr-only">
Heti horoszkóp, {weekRange(start, end)}
</h2>
{gaveUp || analysis?.status === "failed" ? (
<p className="muted" role="status">
{current
? "A heti horoszkóp most nem készült el. Töltsd újra az oldalt egy kicsit később."
: "Ez a heti horoszkóp nem készült el."}
</p>
) : (
<>
<AnalysisLoading
compact
text="A heti horoszkópod készül, ez fél percig is eltarthat…"
since={analysis?.requested_at ?? analysis?.created_at}
/>
{analysis && (
<RetryNotice
status={analysis.status}
error={analysis.error}
nextAttemptAt={analysis.next_attempt_at}
isAdmin={isAdmin}
/>
)}
</>
)}
</>
)}
</article>
);
}
+1
View File
@@ -29,6 +29,7 @@ export const TAG_LABELS: Record<string, string> = {
export const KIND_LABELS: Record<string, string> = {
summary: "Rövid összefoglaló",
weekly: "Heti horoszkóp",
natal: "Képletelemzés",
synastry: "Kapcsolati elemzés",
forecast: "Éves előrejelzés",
+8 -2
View File
@@ -31,6 +31,8 @@ export interface Me {
nps_due: boolean;
/** Natal analyses earned by bringing new users through shared links. */
referral_rewards: { earned: number; limit: number };
/** Monday's e-mail about the weekly horoscope is on. */
weekly_email: boolean;
}
/** A package from the catalog (`GET /v1/packages`). */
@@ -258,7 +260,7 @@ export interface SynastryListItem {
export interface Analysis {
id: string;
kind: "natal" | "synastry" | "summary" | "forecast" | "celebrity";
kind: "natal" | "synastry" | "summary" | "forecast" | "celebrity" | "weekly";
status: "pending" | "running" | "done" | "failed";
model: string;
language: string;
@@ -272,6 +274,8 @@ export interface Analysis {
next_attempt_at?: string;
/** When the current text was asked for: the waiting page counts from here. */
requested_at?: string;
/** The Monday of a weekly horoscope. */
week_start?: string | null;
}
/** Admin: one failed attempt in the error log. */
@@ -325,7 +329,7 @@ export interface ModelFunction {
export interface AdminJob {
id: string;
type: "analysis" | "question";
kind: "summary" | "natal" | "synastry" | "forecast" | "question" | "celebrity";
kind: "summary" | "natal" | "synastry" | "forecast" | "question" | "celebrity" | "weekly";
status: "pending" | "running";
/** The model of the current attempt. */
model: string;
@@ -467,6 +471,8 @@ export interface AdminCelebrityRow {
export interface AnalysisContent {
title?: string;
summary?: string;
/** The weekly horoscope's paragraphs. */
text?: string;
sections?: Record<string, { title: string; body: string }>;
strengths?: string[];
challenges?: string[];