From cba70310f91768a1c1fd10de819961d4bce803de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leon=20Tonh=C3=A4user?=
Date: Tue, 1 Dec 2026 00:09:37 +0100
Subject: [PATCH] Release 2.4.0: bulk download rework, toasts and Sakani polish
- ZIP download from the Merkzettel: every photo is a new usage by
default; only already downloaded photos offer "Neu / Bereits genutzt"
(SegmentedControl), with thumbnails and a cost summary. "Bild
auslassen" is gone.
- Toasts (Sakani Toaster) for admin saves, deletes and errors; billing
errors are readable and use router.refresh instead of reloads. Errors
inside modal dialogs stay inline (a toast would sit behind the
backdrop).
- Album overview in blog-listing style, Sakani Pagination for albums,
search and usage history, skeleton loading states.
- Registration stepper; verification mail lands on step 3.
- Editorials as a searchable, filterable table; audit log with event
picker, German labels and collapsible details.
- Release notes 2.4.0 seeded (migration 0009).
Co-Authored-By: Claude Opus 5.5
---
AGENTS.md | 3 +-
AI_MEMORY.md | 9 +
drizzle/0009_release_notes_2_4_0.sql | 6 +
drizzle/meta/0009_snapshot.json | 2585 +++++++++++++++++
drizzle/meta/_journal.json | 7 +
.../(public)/registrieren/bestaetigt/page.tsx | 20 +-
src/app/(public)/registrieren/page.tsx | 2 +
.../[editorialId]/BillingSelection.test.tsx | 4 +-
.../[editorialId]/BillingSelection.tsx | 120 +-
src/app/admin/alben/AlbumAccessManager.tsx | 16 +-
src/app/admin/audit/page.tsx | 104 +-
src/app/admin/hinweise/AnnouncementForm.tsx | 11 +-
.../hinweise/DeleteAnnouncementButton.tsx | 7 +-
src/app/admin/kalender/CalendarEventForm.tsx | 11 +-
.../kalender/DeleteCalendarEventButton.tsx | 11 +-
.../kalender/kategorien/CategoryForm.tsx | 11 +-
.../kategorien/DeleteCategoryButton.tsx | 11 +-
src/app/admin/redaktionen/EditorialsTable.tsx | 145 +
.../redaktionen/[id]/alben/AlbumGrid.tsx | 6 +-
.../redaktionen/[id]/alben/page.test.tsx | 2 +
.../redaktionen/[id]/auto-regeln/page.tsx | 13 +-
src/app/admin/redaktionen/page.tsx | 104 +-
.../versionen/DeleteReleaseNoteButton.tsx | 7 +-
src/app/admin/versionen/ReleaseNoteForm.tsx | 11 +-
src/app/globals.css | 9 +
src/app/layout.tsx | 2 +
src/app/redaktion/alben/[albumId]/loading.tsx | 16 +-
src/app/redaktion/alben/loading.tsx | 22 +-
src/app/redaktion/alben/page.tsx | 17 +-
.../redaktion/kalender/EventAccessAction.tsx | 26 +-
.../DownloadLightboxForm.test.tsx | 62 +-
.../leuchtkasten/DownloadLightboxForm.tsx | 243 +-
src/app/redaktion/nutzungen/page.test.tsx | 8 +-
.../nutzungen/usage-history-content.tsx | 10 +-
src/components/download/usage-dialog.tsx | 5 +-
src/components/layout/registration-steps.tsx | 23 +
src/components/layout/release-notes.tsx | 23 +-
src/components/ui/feedback.tsx | 72 +
src/components/ui/sakani.tsx | 2 +-
src/components/ui/url-pagination.tsx | 36 +
src/modules/albums/catalog-content.test.tsx | 6 +-
src/modules/albums/catalog-content.tsx | 71 +-
src/modules/albums/photo-gallery.tsx | 5 +-
src/modules/auth/auth.ts | 2 +-
src/modules/editorials/ApproveForm.tsx | 5 +-
src/modules/editorials/DangerZone.tsx | 9 +-
src/modules/editorials/ResetUsageCard.tsx | 7 +-
src/modules/editorials/admin-detail.tsx | 21 +-
48 files changed, 3474 insertions(+), 454 deletions(-)
create mode 100644 drizzle/0009_release_notes_2_4_0.sql
create mode 100644 drizzle/meta/0009_snapshot.json
create mode 100644 src/app/admin/redaktionen/EditorialsTable.tsx
create mode 100644 src/components/layout/registration-steps.tsx
create mode 100644 src/components/ui/feedback.tsx
create mode 100644 src/components/ui/url-pagination.tsx
diff --git a/AGENTS.md b/AGENTS.md
index f9652b8..0f68977 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -26,7 +26,8 @@ Aktueller Stand: siehe neueste Einträge in `release_notes` (Basis `2.0.0`,
Kalender/Selbstbedienung/Sortierung/Beschreibung: `2.1.0`,
Dateiname-Suche: `2.1.1`, Statistik/Collab/Rechnungsversand: `2.2.0`,
Quartalsabrechnung + Sakani-Formulare: `2.2.1`, Versionshistorie: `2.2.2`,
-Kategorien/Vormerken/Monatskalender/Dashboard: `2.3.0`).
+Kategorien/Vormerken/Monatskalender/Dashboard: `2.3.0`,
+Mehrfach-Download/Toasts/Sakani-Feinschliff: `2.4.0`).
## Sicherheit (bei jeder Änderung mitprüfen)
diff --git a/AI_MEMORY.md b/AI_MEMORY.md
index feddc3d..3718cb6 100644
--- a/AI_MEMORY.md
+++ b/AI_MEMORY.md
@@ -92,3 +92,12 @@ Redaktionen können Bilder durchsuchen, einen Leuchtkasten verwenden, Bilder her
- **Dashboard (`/admin`):** `src/modules/dashboard/tasks.ts` (rein, getestet) + `queries.ts` (Aufgaben-Zähler), Rest aus `statsQueries.loadOverview(30)` und `calendarService.listAdminEvents()`.
- **drizzle-kit generate ohne TTY:** Fragt bei "neue Tabelle + gelöschte Tabelle" interaktiv nach Umbenennung und bricht ohne Terminal ab. Lösung: in zwei Schritten generieren (erst hinzufügen, dann löschen), so entstanden 0006 und 0007.
+## 12. Mehrfach-Download, Toasts, Sakani-Feinschliff (Stand 2026-11, v2.4)
+- **Toasts:** Ein `` (Sakani `Toaster`, unten rechts) im Root-Layout. Helfer in `src/components/ui/feedback.tsx`: `notifyResult(result, fallback)` für Actions mit `{ ok, message }`, `useResultToast(state)` für `useActionState`, `ToastForm` für Server-Actions ohne Rückgabe (Speichern + `router.refresh()`). Bei Seiten, die vorher `window.location.reload()` nutzten (Abrechnungen), jetzt `router.refresh()`, sonst wäre der Toast weg.
+- **Toasts nicht in modalen Dialogen:** Native `
- {error && }
);
}
@@ -535,10 +518,10 @@ type CancelReportFormProps = {
};
function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
+ const router = useRouter();
const [reason, setReason] = useState("");
const [confirmed, setConfirmed] = useState(false);
const [loading, setLoading] = useState(false);
- const [error, setError] = useState(null);
const trimmed = reason.trim();
const valid = trimmed.length >= 5 && trimmed.length <= 500 && confirmed;
@@ -547,7 +530,6 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
event.preventDefault();
if (!valid) return;
setLoading(true);
- setError(null);
try {
const response = await fetch(`/api/billing-reports/${encodeURIComponent(reportId)}/cancel`, {
method: "POST",
@@ -556,13 +538,14 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
});
if (!response.ok) {
const body = await response.json().catch(() => ({ code: "ERROR" }));
- throw new Error(body.code ?? "Stornierung fehlgeschlagen");
+ throw new Error(billingErrorMessage(body.code));
}
- window.location.reload();
+ toast.success(`Bericht Nr. ${reportNumber} storniert. Die Nutzungen sind wieder offen.`);
+ router.refresh();
} catch (err) {
- setError(err instanceof Error ? err.message : "Stornierung fehlgeschlagen");
- setLoading(false);
+ toast.error(err instanceof Error ? err.message : billingErrorMessage(null));
}
+ setLoading(false);
}
return (
@@ -587,7 +570,30 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
{loading ? "Wird storniert …" : "Stornieren"}
- {error && }
);
}
+
+function billingErrorMessage(code: unknown): string {
+ switch (code) {
+ case "NO_USAGES_SELECTED":
+ return "Bitte mindestens eine offene Nutzung auswählen.";
+ case "USAGE_NOT_ELIGIBLE":
+ case "USAGE_NOT_FOUND":
+ return "Eine der gewählten Nutzungen ist nicht mehr abrechenbar. Bitte die Seite neu laden.";
+ case "ADDRESS_NOT_FOUND":
+ return "Für diese Redaktion fehlt die Rechnungsadresse.";
+ case "EDITORIAL_NOT_FOUND":
+ return "Diese Redaktion existiert nicht mehr.";
+ case "REPORT_NOT_FOUND":
+ return "Dieser Bericht existiert nicht mehr.";
+ case "INVALID_CANCELLATION_REASON":
+ return "Bitte einen Stornierungsgrund mit 5 bis 500 Zeichen angeben.";
+ case "REPORT_NUMBER_COLLISION":
+ return "Die Berichtsnummer war gerade vergeben. Bitte erneut versuchen.";
+ case "RATE_LIMITED":
+ return "Zu viele Versuche. Bitte kurz warten.";
+ default:
+ return "Der Vorgang ist fehlgeschlagen. Bitte erneut versuchen.";
+ }
+}
diff --git a/src/app/admin/alben/AlbumAccessManager.tsx b/src/app/admin/alben/AlbumAccessManager.tsx
index 927706c..dc88ac2 100644
--- a/src/app/admin/alben/AlbumAccessManager.tsx
+++ b/src/app/admin/alben/AlbumAccessManager.tsx
@@ -5,12 +5,13 @@
import { useActionState, useMemo, useState, useTransition } from "react";
import Link from "next/link";
-import { Alert, Checkbox, EmptyState, Input, Table } from "@sakaniui/react";
+import { Checkbox, EmptyState, Input, Table } from "@sakaniui/react";
import { IconSearch, IconX } from "@sakaniui/react/icons";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import type { AlbumAccessActionResult } from "./actions";
+import { notifyResult, useResultToast } from "@/components/ui/feedback";
type AccessAction = (
state: AlbumAccessActionResult,
@@ -42,12 +43,12 @@ export function AlbumAccessManager({
bulkGrantAction: AccessAction;
revokeAction: AccessAction;
}>) {
- const [bulkState, setBulkState] = useState(INITIAL_RESULT);
const [bulkPending, startBulkTransition] = useTransition();
const [revokeState, revokeFormAction, revokePending] = useActionState(
revokeAction,
INITIAL_RESULT,
);
+ useResultToast(revokeState);
const [selectedAlbumIds, setSelectedAlbumIds] = useState>(new Set());
const [selectedEditorialIds, setSelectedEditorialIds] = useState>(new Set());
const [bulkSearch, setBulkSearch] = useState("");
@@ -58,7 +59,7 @@ export function AlbumAccessManager({
const handleBulkSubmit = (formData: FormData) => {
startBulkTransition(async () => {
const result = await bulkGrantAction(INITIAL_RESULT, formData);
- setBulkState(result);
+ notifyResult(result);
if (result.ok && result.grantedCount > 0) {
setSelectedAlbumIds(new Set());
setSelectedEditorialIds(new Set());
@@ -255,13 +256,9 @@ export function AlbumAccessManager({
- {bulkState.message ? (
-
- ) : (
-
+
Wähle mindestens ein Album und eine Redaktion aus.
- )}
@@ -291,9 +288,6 @@ export function AlbumAccessManager({
- {revokeState.message ? (
-
- ) : null}
{albums.length === 0 ? (
diff --git a/src/app/admin/audit/page.tsx b/src/app/admin/audit/page.tsx
index f4e1cac..253a648 100644
--- a/src/app/admin/audit/page.tsx
+++ b/src/app/admin/audit/page.tsx
@@ -2,7 +2,9 @@ import Link from "next/link";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
-import { Card, DataTable, EmptyState, Input } from "@/components/ui/sakani";
+import { Badge, Card, DataTable, EmptyState, FormSelect, Input } from "@/components/ui/sakani";
+import { db } from "@/db/client";
+import { auditEvents } from "@/db/schema";
import { listAuditEvents, type AuditEventRow } from "@/modules/audit/queries";
import { requireAdminPage } from "../access";
@@ -24,14 +26,21 @@ export default async function AuditPage({ searchParams }: { searchParams: Search
const dateTo = firstParam(params, "dateTo");
const cursor = firstParam(params, "cursor");
- const page = await listAuditEvents(
+ const [page, typeRows] = await Promise.all([
+ listAuditEvents(
{
eventType: eventType || undefined,
dateFrom: dateFrom ? berlinDateToUtc(dateFrom) : undefined,
dateTo: dateTo ? berlinDateToUtcEndOfDay(dateTo) : undefined,
},
- cursor || null,
- );
+ cursor || null,
+ ),
+ db.selectDistinct({ eventType: auditEvents.eventType }).from(auditEvents).orderBy(auditEvents.eventType),
+ ]);
+ const typeOptions = [
+ { label: "Alle Ereignisse", value: "" },
+ ...typeRows.map(({ eventType: type }) => ({ label: eventLabel(type), value: type })),
+ ];
return (
@@ -44,7 +53,7 @@ export default async function AuditPage({ searchParams }: { searchParams: Search
);
diff --git a/src/app/admin/hinweise/DeleteAnnouncementButton.tsx b/src/app/admin/hinweise/DeleteAnnouncementButton.tsx
index 10012c7..dd421a3 100644
--- a/src/app/admin/hinweise/DeleteAnnouncementButton.tsx
+++ b/src/app/admin/hinweise/DeleteAnnouncementButton.tsx
@@ -7,6 +7,7 @@ import { IconTrash } from "@sakaniui/react/icons";
import { Button } from "@/components/ui/button";
import type { AnnouncementActionResult } from "./actions";
+import { useResultToast } from "@/components/ui/feedback";
// One tiny form per announcement row so every delete button reports its own
// result inline (same pattern as AlbumGrantForm).
@@ -21,6 +22,7 @@ export function DeleteAnnouncementButton({
announcementId: string;
}>) {
const [state, formAction, pending] = useActionState(action, { ok: true, message: "" });
+ useResultToast(state, "Hinweis gelöscht.");
return (
);
}
diff --git a/src/app/admin/kalender/CalendarEventForm.tsx b/src/app/admin/kalender/CalendarEventForm.tsx
index b4e506f..caccb34 100644
--- a/src/app/admin/kalender/CalendarEventForm.tsx
+++ b/src/app/admin/kalender/CalendarEventForm.tsx
@@ -2,12 +2,13 @@
import { useId, useState, useTransition } from "react";
-import { Alert, Input } from "@sakaniui/react";
+import { Input } from "@sakaniui/react";
import { Button } from "@/components/ui/button";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { CalendarActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
export function CalendarEventForm({
action,
@@ -22,14 +23,13 @@ export function CalendarEventForm({
}>) {
const titleId = useId();
const dateId = useId();
- const [state, setState] = useState({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const [title, setTitle] = useState("");
const handleSubmit = (formData: FormData) => {
startTransition(async () => {
const result = await action({ ok: true, message: "" }, formData);
- setState(result);
+ notifyResult(result);
if (result.ok) {
setTitle("");
}
@@ -80,11 +80,6 @@ export function CalendarEventForm({
{pending ? "Wird angelegt …" : "Termin anlegen"}
- {state.message ? (
-
- ) : null}
);
diff --git a/src/app/admin/kalender/DeleteCalendarEventButton.tsx b/src/app/admin/kalender/DeleteCalendarEventButton.tsx
index 4b0ff7b..10b770b 100644
--- a/src/app/admin/kalender/DeleteCalendarEventButton.tsx
+++ b/src/app/admin/kalender/DeleteCalendarEventButton.tsx
@@ -1,10 +1,11 @@
"use client";
-import { useState, useTransition } from "react";
+import { useTransition } from "react";
import { Button } from "@/components/ui/button";
import type { CalendarActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
// Deleting an event also revokes self-service grants on its linked album, so
// the admin confirms once before the action runs.
@@ -15,7 +16,6 @@ export function DeleteCalendarEventButton({
action: (state: CalendarActionResult, formData: FormData) => Promise;
eventId: string;
}>) {
- const [state, setState] = useState({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const handleClick = () => {
@@ -25,7 +25,7 @@ export function DeleteCalendarEventButton({
const formData = new FormData();
formData.set("eventId", eventId);
startTransition(async () => {
- setState(await action({ ok: true, message: "" }, formData));
+ notifyResult(await action({ ok: true, message: "" }, formData), "Termin gelöscht.");
});
};
@@ -34,11 +34,6 @@ export function DeleteCalendarEventButton({
- {state.ok ? null : (
-
- {state.message}
-
- )}
);
}
diff --git a/src/app/admin/kalender/kategorien/CategoryForm.tsx b/src/app/admin/kalender/kategorien/CategoryForm.tsx
index 1c350c2..1be4938 100644
--- a/src/app/admin/kalender/kategorien/CategoryForm.tsx
+++ b/src/app/admin/kalender/kategorien/CategoryForm.tsx
@@ -1,7 +1,7 @@
"use client";
import { useId, useState, useTransition } from "react";
-import { Alert, Input } from "@sakaniui/react";
+import { Input } from "@sakaniui/react";
import { CategoryDot } from "@/components/calendar/category-legend";
import { Button } from "@/components/ui/button";
@@ -9,6 +9,7 @@ import { Card } from "@/components/ui/sakani";
import { CATEGORY_COLOR_LABELS, CATEGORY_COLORS, type CategoryColor } from "@/modules/calendar/colors";
import type { CategoryActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
export function CategoryForm({
action,
@@ -16,13 +17,12 @@ export function CategoryForm({
const nameId = useId();
const [name, setName] = useState("");
const [color, setColor] = useState("blue");
- const [state, setState] = useState({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const handleSubmit = (formData: FormData) => {
startTransition(async () => {
const result = await action({ ok: true, message: "" }, formData);
- setState(result);
+ notifyResult(result);
if (result.ok) setName("");
});
};
@@ -73,11 +73,6 @@ export function CategoryForm({
{pending ? "Wird gespeichert …" : "Kategorie speichern"}
- {state.message ? (
-
- ) : null}
);
diff --git a/src/app/admin/kalender/kategorien/DeleteCategoryButton.tsx b/src/app/admin/kalender/kategorien/DeleteCategoryButton.tsx
index 70f640c..937aceb 100644
--- a/src/app/admin/kalender/kategorien/DeleteCategoryButton.tsx
+++ b/src/app/admin/kalender/kategorien/DeleteCategoryButton.tsx
@@ -1,10 +1,11 @@
"use client";
-import { useState, useTransition } from "react";
+import { useTransition } from "react";
import { Button } from "@/components/ui/button";
import type { CategoryActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
export function DeleteCategoryButton({
action,
@@ -15,13 +16,12 @@ export function DeleteCategoryButton({
categoryId: string;
inUse: boolean;
}>) {
- const [state, setState] = useState({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const handleClick = () => {
const formData = new FormData();
formData.set("categoryId", categoryId);
- startTransition(async () => setState(await action({ ok: true, message: "" }, formData)));
+ startTransition(async () => notifyResult(await action({ ok: true, message: "" }, formData), "Kategorie gelöscht."));
};
return (
@@ -36,11 +36,6 @@ export function DeleteCategoryButton({
>
{pending ? "…" : "Löschen"}
- {state.ok ? null : (
-
- {state.message}
-
- )}
);
}
diff --git a/src/app/admin/redaktionen/EditorialsTable.tsx b/src/app/admin/redaktionen/EditorialsTable.tsx
new file mode 100644
index 0000000..75bbb85
--- /dev/null
+++ b/src/app/admin/redaktionen/EditorialsTable.tsx
@@ -0,0 +1,145 @@
+"use client";
+
+import { useMemo, useState } from "react";
+import Link from "next/link";
+import { Badge, EmptyState, Input, SegmentedControl, Table, type TableColumn } from "@sakaniui/react";
+import { IconSearch } from "@sakaniui/react/icons";
+
+export type EditorialRow = {
+ id: string;
+ name: string;
+ contactName: string;
+ loginEmail: string;
+ status: string;
+ archived: boolean;
+ priceCents: number | null;
+ openCents: number;
+ createdAt: string;
+};
+
+type StatusKey = "active" | "pending" | "suspended" | "archived";
+
+const STATUS: Record = {
+ active: { label: "Aktiv", variant: "success" },
+ pending: { label: "Ausstehend", variant: "warning" },
+ suspended: { label: "Gesperrt", variant: "danger" },
+ archived: { label: "Archiviert", variant: "neutral" },
+};
+
+function statusOf(row: EditorialRow): StatusKey {
+ if (row.archived) return "archived";
+ if (row.status === "active") return "active";
+ if (row.status === "pending_email" || row.status === "pending_approval") return "pending";
+ return "suspended";
+}
+
+const euro = new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" });
+const date = new Intl.DateTimeFormat("de-DE", { dateStyle: "medium", timeZone: "Europe/Berlin" });
+
+type Row = EditorialRow & { statusCell?: never; priceCell?: never; openCell?: never; createdCell?: never };
+
+const columns: TableColumn[] = [
+ {
+ key: "name",
+ header: "Redaktion",
+ render: (row) => (
+
+
+ {row.name}
+
+ {row.loginEmail}
+
+ ),
+ },
+ { key: "contactName", header: "Kontakt" },
+ {
+ key: "statusCell",
+ header: "Status",
+ render: (row) => {
+ const status = STATUS[statusOf(row)];
+ return {status.label};
+ },
+ },
+ {
+ key: "priceCell",
+ header: "Preis netto",
+ align: "right",
+ render: (row) => (
+ {row.priceCents === null ? "offen" : euro.format(row.priceCents / 100)}
+ ),
+ },
+ {
+ key: "openCell",
+ header: "Nicht abgerechnet",
+ align: "right",
+ render: (row) => (
+ 0 ? "font-medium text-[var(--color-warning-fg)]" : "text-[var(--color-fg-muted)]"}`}>
+ {euro.format(row.openCents / 100)}
+
+ ),
+ },
+ {
+ key: "createdCell",
+ header: "Registriert",
+ align: "right",
+ render: (row) => {date.format(new Date(row.createdAt))},
+ },
+];
+
+const FILTERS = [
+ { value: "all", label: "Alle" },
+ { value: "active", label: "Aktiv" },
+ { value: "pending", label: "Ausstehend" },
+ { value: "suspended", label: "Gesperrt" },
+ { value: "archived", label: "Archiviert" },
+];
+
+export function EditorialsTable({ rows }: Readonly<{ rows: EditorialRow[] }>) {
+ const [query, setQuery] = useState("");
+ const [filter, setFilter] = useState("all");
+
+ const visible = useMemo(() => {
+ const needle = query.trim().toLowerCase();
+ return rows.filter((row) => {
+ const status = statusOf(row);
+ // "Alle" hides archived accounts; they have their own filter.
+ if (filter === "all" ? status === "archived" : status !== filter) return false;
+ return !needle || [row.name, row.contactName, row.loginEmail].some((value) => value.toLowerCase().includes(needle));
+ });
+ }, [rows, query, filter]);
+
+ return (
+
+
+
+
+
+
+ }
+ onChange={(event) => setQuery(event.target.value)}
+ placeholder="Name, Kontakt oder E-Mail …"
+ type="search"
+ value={query}
+ />
+
+
+
+ {visible.length === 0 ? (
+
+ ) : (
+
columns={columns} rowKey={(row) => row.id} rows={visible} />
+ )}
+
+ {visible.length} von {rows.length} Redaktionen
+
+
+ );
+}
diff --git a/src/app/admin/redaktionen/[id]/alben/AlbumGrid.tsx b/src/app/admin/redaktionen/[id]/alben/AlbumGrid.tsx
index 82e19a5..ebcd0fe 100644
--- a/src/app/admin/redaktionen/[id]/alben/AlbumGrid.tsx
+++ b/src/app/admin/redaktionen/[id]/alben/AlbumGrid.tsx
@@ -9,6 +9,7 @@ import { IconMail, IconSearch } from "@sakaniui/react/icons";
import { Card } from "@/components/ui/sakani";
import type { AlbumActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
type AlbumGridAction = (
editorialId: string,
@@ -46,9 +47,9 @@ function AlbumCard({ album, editorialId, grantAction, revokeAction, notifyAction
startTransition(async () => {
const initial: AlbumActionResult = { ok: true, message: "" };
if (album.isGranted) {
- await revokeAction(editorialId, initial, formData);
+ notifyResult(await revokeAction(editorialId, initial, formData), "Zuweisung aufgehoben.");
} else {
- await grantAction(editorialId, initial, formData);
+ notifyResult(await grantAction(editorialId, initial, formData), "Album zugewiesen.");
}
});
};
@@ -99,6 +100,7 @@ function AlbumCard({ album, editorialId, grantAction, revokeAction, notifyAction
setNotifyStatus("pending");
notifyAction(editorialId, { ok: true, message: "" }, formData).then((res) => {
setNotifyStatus(res.ok ? "success" : "error");
+ notifyResult(res, "E-Mail an die Redaktion gesendet.");
setTimeout(() => setNotifyStatus("idle"), 3000);
});
}}
diff --git a/src/app/admin/redaktionen/[id]/alben/page.test.tsx b/src/app/admin/redaktionen/[id]/alben/page.test.tsx
index 00a0824..0b1bbd2 100644
--- a/src/app/admin/redaktionen/[id]/alben/page.test.tsx
+++ b/src/app/admin/redaktionen/[id]/alben/page.test.tsx
@@ -3,6 +3,8 @@
import { render, screen } from "@testing-library/react";
import { expect, test, vi } from "vitest";
+vi.mock("next/navigation", () => ({ useRouter: () => ({ refresh: vi.fn(), push: vi.fn() }) }));
+
import { EditorialDetailContent } from "@/modules/editorials/admin-detail";
import { AlbumGrantError } from "@/modules/albums/grants";
import { loadAssignableAlbums } from "./page-content";
diff --git a/src/app/admin/redaktionen/[id]/auto-regeln/page.tsx b/src/app/admin/redaktionen/[id]/auto-regeln/page.tsx
index ba846b5..7ddec8a 100644
--- a/src/app/admin/redaktionen/[id]/auto-regeln/page.tsx
+++ b/src/app/admin/redaktionen/[id]/auto-regeln/page.tsx
@@ -14,6 +14,7 @@ import { PageHeader } from "@/components/ui/page-header";
import { requireAdminPage } from "../../../access";
import { applyAutoRulesAction, createAutoRuleAction, deleteAutoRuleAction } from "./actions";
+import { ToastForm } from "@/components/ui/feedback";
type AutoRulesPageProps = Readonly<{
params: Promise<{ id: string }>;
@@ -51,14 +52,14 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
-
+
@@ -71,11 +72,11 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
Alle derzeit aktiven automatischen Zuweisungen.
-
+
@@ -91,11 +92,11 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
Erstellt am {new Date(rule.createdAt).toLocaleDateString('de-DE')}
-
+
))}
diff --git a/src/app/admin/redaktionen/page.tsx b/src/app/admin/redaktionen/page.tsx
index 028deac..84084d7 100644
--- a/src/app/admin/redaktionen/page.tsx
+++ b/src/app/admin/redaktionen/page.tsx
@@ -3,10 +3,13 @@ import Link from "next/link";
import { db } from "@/db/client";
import { editorialAccounts, usages } from "@/db/schema";
import { PageHeader } from "@/components/ui/page-header";
-import { IconChevronRight } from "@sakaniui/react/icons";
-import { Badge, Card, EmptyState } from "@/components/ui/sakani";
+import { EmptyState } from "@/components/ui/sakani";
+
+import { requireAdminPage } from "../access";
+import { EditorialsTable } from "./EditorialsTable";
export default async function EditorialsPage() {
+ await requireAdminPage();
const [editorials, openUsageTotals] = await Promise.all([
db
.select({
@@ -37,96 +40,31 @@ export default async function EditorialsPage() {
openUsageTotals.map((total) => [total.editorialId, total.openCents]),
);
- const activeEditorials = editorials.filter((e) => !e.archivedAt);
- const archivedEditorials = editorials.filter((e) => e.archivedAt);
-
return (
- {activeEditorials.length === 0 ? (
-
+ {editorials.length === 0 ? (
+
) : (
-
- {activeEditorials.map((editorial) => {
- const openCents = openCentsByEditorial.get(editorial.id) ?? 0;
- return (
- -
-
-
-
-
{editorial.name}
-
- {STATUS[editorial.status]?.label ?? "Gesperrt"}
-
-
-
- - Kontakt
- - {editorial.contactName}
- - E-Mail
- - {editorial.loginEmail}
-
-
- {editorial.currentPriceCents === null
- ? "Preis noch nicht festgelegt"
- : `Netto ${formatCents(editorial.currentPriceCents)}`}
- 0 ? "text-[var(--color-warning-fg)]" : "text-[var(--color-fg-muted)]"}`}
- title="Summe der noch nicht abgerechneten Bildnutzungen"
- >
- · Offen {formatCents(openCents)}
-
-
-
-
-
- );
- })}
-
- )}
-
- {archivedEditorials.length > 0 && (
-
-
-
- Archivierte Redaktionen ({archivedEditorials.length})
-
-
- {archivedEditorials.map((editorial) => (
- -
-
-
-
-
{editorial.name}
- Archiviert
-
- {editorial.contactName} · {editorial.loginEmail}
-
- Archiviert am: {editorial.archivedAt ? new Date(editorial.archivedAt).toLocaleDateString("de-DE") : ""}
-
-
-
-
- ))}
-
-
+ ({
+ id: editorial.id,
+ name: editorial.name,
+ contactName: editorial.contactName,
+ loginEmail: editorial.loginEmail,
+ status: editorial.status,
+ archived: Boolean(editorial.archivedAt),
+ priceCents: editorial.currentPriceCents,
+ openCents: openCentsByEditorial.get(editorial.id) ?? 0,
+ createdAt: editorial.createdAt.toISOString(),
+ }))}
+ />
)}
);
}
-
-const CARD_LINK =
- "block h-full rounded-[var(--radius-xl)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]";
-
-const STATUS: Record = {
- active: { label: "Aktiv", variant: "success" },
- pending_approval: { label: "Ausstehend", variant: "warning" },
-};
-
-function formatCents(cents: number): string {
- return new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(cents / 100);
-}
\ No newline at end of file
diff --git a/src/app/admin/versionen/DeleteReleaseNoteButton.tsx b/src/app/admin/versionen/DeleteReleaseNoteButton.tsx
index 2c1d3d9..aa4e7d7 100644
--- a/src/app/admin/versionen/DeleteReleaseNoteButton.tsx
+++ b/src/app/admin/versionen/DeleteReleaseNoteButton.tsx
@@ -5,6 +5,7 @@ import { useActionState } from "react";
import { Button } from "@/components/ui/button";
import type { ReleaseNoteActionResult } from "./actions";
+import { useResultToast } from "@/components/ui/feedback";
export function DeleteReleaseNoteButton({
action,
@@ -14,6 +15,7 @@ export function DeleteReleaseNoteButton({
noteId: string;
}>) {
const [state, formAction, pending] = useActionState(action, { ok: true, message: "" });
+ useResultToast(state, "Versionshinweis gelöscht.");
return (
);
}
diff --git a/src/app/admin/versionen/ReleaseNoteForm.tsx b/src/app/admin/versionen/ReleaseNoteForm.tsx
index 7631c24..b03ec90 100644
--- a/src/app/admin/versionen/ReleaseNoteForm.tsx
+++ b/src/app/admin/versionen/ReleaseNoteForm.tsx
@@ -2,12 +2,13 @@
import { useId, useState, useTransition } from "react";
-import { Alert, Input, Textarea } from "@sakaniui/react";
+import { Input, Textarea } from "@sakaniui/react";
import { Button } from "@/components/ui/button";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { ReleaseNoteActionResult } from "./actions";
+import { notifyResult } from "@/components/ui/feedback";
export function ReleaseNoteForm({
action,
@@ -16,14 +17,13 @@ export function ReleaseNoteForm({
}>) {
const versionId = useId();
const bodyId = useId();
- const [state, setState] = useState({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const [body, setBody] = useState("");
const handleSubmit = (formData: FormData) => {
startTransition(async () => {
const result = await action({ ok: true, message: "" }, formData);
- setState(result);
+ notifyResult(result);
if (result.ok) {
setBody("");
}
@@ -67,11 +67,6 @@ export function ReleaseNoteForm({
{pending ? "Wird veröffentlicht …" : "Hinweis veröffentlichen"}
- {state.message ? (
-
- ) : null}
);
diff --git a/src/app/globals.css b/src/app/globals.css
index 03102d2..d44e474 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -208,7 +208,15 @@ body:has([data-app-shell]) .legal-footer {
background: var(--contact-sheet);
}
+.photo-tile-skeleton {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+}
+
.photo-tile-trigger {
+ position: relative;
display: block;
width: 100%;
margin: 0;
@@ -220,6 +228,7 @@ body:has([data-app-shell]) .legal-footer {
}
.photo-tile-image {
+ position: relative;
display: block;
width: 100%;
height: auto;
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index df78d61..1904b36 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -10,6 +10,7 @@ import "./globals.css";
import { LegalFooter } from "@/components/layout/legal-footer";
import { ThemeProvider } from "@/components/theme-provider";
+import { AppToaster } from "@/components/ui/feedback";
export const metadata: Metadata = {
title: "Redaktionsportal | Leon Tonhäuser",
@@ -34,6 +35,7 @@ export default function RootLayout({ children }: Readonly<{ children: ReactNode
{children}
+