- Billing is always quarterly: the billing page opens the current quarter, the month view is gone, old ?month= links land in their quarter and invalid quarters no longer throw. - Calendar and release-note forms and the RSVP buttons use Sakani components (Card, Input, Textarea, FormSelect, Button, Alert). - Sidebar logo stays visible in dark mode (Sakani's logo tile is light). - Release notes for 2.2.1 seeded via custom migration 0004; popup version bumped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
4.4 KiB
TypeScript
107 lines
4.4 KiB
TypeScript
"use client";
|
||
|
||
import { useEffect, useRef } from "react";
|
||
import { Button } from "@sakaniui/react";
|
||
import { IconCheck } from "@sakaniui/react/icons";
|
||
|
||
// Bump RELEASE.version for the next release and replace the notes: every user
|
||
// then sees the popup once more. ponytail: only the latest release is kept;
|
||
// add a history list when users ask for older notes.
|
||
export const RELEASE = {
|
||
version: "2.2.1",
|
||
title: "Kalender, Statistiken, Collab und Rechnungen",
|
||
notes: {
|
||
redaktion: [
|
||
"Neuer Kalender: kommende Termine sehen, zurückmelden ob Sie da sind, und das verknüpfte Album selbst freischalten.",
|
||
"Die Suche findet jetzt auch Dateinamen; Merkzettel-Links führen direkt zum richtigen Bild.",
|
||
"Fotos lassen sich nach ältesten und neuesten sortieren; die Bildbeschreibung erscheint in der Großansicht.",
|
||
"Wenn Ihre Redaktion für Collab freigeschaltet ist, können Sie Downloads als kostenlose Collab-Nutzung markieren (auch für mehrere Bilder vom Merkzettel).",
|
||
"Rechnung und Nutzungsnachweis kommen gebündelt per E-Mail, sobald die Rechnung vorliegt.",
|
||
"Alle Versionshinweise finden Sie unter Neuigkeiten.",
|
||
],
|
||
admin: [
|
||
"Neue Statistik-Seite: Downloads, Datenmenge, Aufrufe, Suchen, Umsatz und Collab-Quote mit Zeitraum-Vergleich.",
|
||
"Kalender unter /admin/kalender: Termine anlegen, Alben verknüpfen, Zusagen der Redaktionen einsehen.",
|
||
"Collab-Nutzung je Redaktion freischalten; Collab-Positionen erscheinen mit 0,00 € in der Abrechnung und lassen sich dort korrigieren.",
|
||
"Rechnungs-PDF je Abrechnung hochladen: danach geht die Rechnung gebündelt mit dem Nutzungsnachweis automatisch per E-Mail raus. Der Nutzungsnachweis wird beim Finalisieren nicht mehr automatisch verschickt.",
|
||
"Abrechnungen laufen immer quartalsweise: Die Abrechnungsseite öffnet direkt das aktuelle Quartal.",
|
||
"Versionshinweise werden unter /admin/versionen gepflegt.",
|
||
],
|
||
},
|
||
} as const;
|
||
|
||
export type ReleaseArea = keyof typeof RELEASE.notes;
|
||
|
||
const seenKey = (area: ReleaseArea) => `release-notes-seen:${area}`;
|
||
|
||
// Per browser, not per account: a courtesy popup, not a record of consent.
|
||
function readSeen(area: ReleaseArea): string | null {
|
||
try {
|
||
return window.localStorage.getItem(seenKey(area));
|
||
} catch {
|
||
return RELEASE.version; // storage blocked: don't nag on every page load
|
||
}
|
||
}
|
||
|
||
function markSeen(area: ReleaseArea) {
|
||
try {
|
||
window.localStorage.setItem(seenKey(area), RELEASE.version);
|
||
} catch {
|
||
/* storage blocked — nothing to persist */
|
||
}
|
||
}
|
||
|
||
// Native <dialog>.showModal() instead of Sakani's Modal: it traps focus, makes
|
||
// the page inert and handles Escape; Sakani's Modal left focus on the page.
|
||
export function ReleaseNotesDialog({
|
||
area,
|
||
open,
|
||
onOpenChange,
|
||
}: Readonly<{ area: ReleaseArea; open: boolean; onOpenChange: (open: boolean) => void }>) {
|
||
const ref = useRef<HTMLDialogElement>(null);
|
||
|
||
// Open once per version, after hydration (localStorage is client-only).
|
||
useEffect(() => {
|
||
if (readSeen(area) !== RELEASE.version) onOpenChange(true);
|
||
}, [area, onOpenChange]);
|
||
|
||
useEffect(() => {
|
||
const dialog = ref.current;
|
||
if (!dialog) return;
|
||
if (open && !dialog.open) dialog.showModal();
|
||
if (!open && dialog.open) dialog.close();
|
||
}, [open]);
|
||
|
||
// Runs for the button, Escape and dialog.close() alike.
|
||
function handleClose() {
|
||
markSeen(area);
|
||
onOpenChange(false);
|
||
}
|
||
|
||
return (
|
||
<dialog ref={ref} aria-labelledby="release-notes-title" className="usage-dialog max-w-lg" onClose={handleClose}>
|
||
<div className="flex flex-col gap-5 p-6">
|
||
<header className="flex flex-col gap-1">
|
||
<p className="text-xs font-medium uppercase tracking-wider text-[var(--color-fg-muted)]">
|
||
Version {RELEASE.version} – {RELEASE.title}
|
||
</p>
|
||
<h2 id="release-notes-title" className="text-xl font-semibold">Was ist neu?</h2>
|
||
</header>
|
||
<ul className="flex flex-col gap-3 text-sm">
|
||
{RELEASE.notes[area].map((note) => (
|
||
<li key={note} className="flex gap-3">
|
||
<IconCheck aria-hidden="true" className="mt-0.5 shrink-0 text-[var(--color-success-fg)]" size={16} />
|
||
<span>{note}</span>
|
||
</li>
|
||
))}
|
||
</ul>
|
||
<div className="flex justify-end">
|
||
<Button autoFocus onClick={() => ref.current?.close()} type="button">
|
||
Verstanden
|
||
</Button>
|
||
</div>
|
||
</div>
|
||
</dialog>
|
||
);
|
||
}
|