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
@@ -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>
);
}