feat: redesign portal UI with Sakani UI and add release notes

Replace the hand-rolled Tailwind/shadcn look with Sakani UI across the
editorial area, the admin area and all signed-out pages.

- AppShell (Sakani Sidebar + TopBar) for /redaktion and /admin, with a
  mobile drawer, theme toggle, sign-out, legal links and a "Was ist neu"
  button; PublicShell for login, registration, password, 2FA and errors.
- Shared primitives (Button, Card, Input, PageHeader) now render Sakani;
  components/ui/sakani.tsx is the client boundary for Server Components
  (Sakani ships no "use client") and adds FormSelect (native form value)
  and DataTable (element cells from the server).
- Legacy CSS variables map onto Sakani tokens; globals.css shrinks from
  ~2200 to ~700 lines. Geist replaces Inter. recharts/lucide-react dropped
  (charts via Sakani BarChart).
- Release notes popup per area, shown once per version (localStorage) and
  reopenable from the sidebar; native <dialog> for focus trapping.
- Fixes found while testing: TOTP field reused the typed password in
  clear text, modal dialogs sat top-left, invisible unchecked checkboxes
  in dark mode.
- Parallel run: compose.parallel.yaml, AUTO_RULE_SYNC_DISABLED switch and
  docs/operations.md §8 (start, rollback, cutover).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude Opus 5.5 committed 2026-11-30 18:24:05 +01:00
1 parent 453bece72c
commit 9e938e4d07
79 files changed
+2266 -4316

No files matched your search

@@ -2,6 +2,11 @@
import { useMemo, useState } from "react";
import Link from "next/link";
import { Alert, Badge, Checkbox, EmptyState, Table, Textarea } from "@sakaniui/react";
import { IconDownload, IconFileText } from "@sakaniui/react/icons";
import { Button } from "@/components/ui/button";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
import { formatCents } from "@/modules/billing/format";
@@ -40,6 +45,12 @@ const STATUS_LABELS: Record<BillingPosition["status"], string> = {
reopened: "Wiedereröffnet",
};
const STATUS_BADGES: Record<BillingPosition["status"], "warning" | "success"> = {
open: "warning",
billed: "success",
reopened: "warning",
};
const REPORT_STATUS_LABELS: Record<string, string> = {
draft: "Entwurf",
final: "Erstellt",
@@ -172,178 +183,162 @@ export function BillingSelection({
<>
<PeriodSelector year={year} month={month} quarter={quarter} isQuarter={isQuarter} />
<div className="billing-selection-controls">
<button type="button" onClick={selectAllOpen} disabled={selectablePositions.length === 0}>
<div className="flex flex-wrap items-center gap-3">
<Button type="button" variant="secondary" onClick={selectAllOpen} disabled={selectablePositions.length === 0}>
{isQuarter ? "Alle offenen im Quartal" : "Alle offenen im Monat"}
</button>
{isQuarter ? (
<Link href={monthHref} className="billing-nav-link">
Monatsansicht
</Link>
) : (
<Link href={quarterHref} className="billing-nav-link">
Ganzes Quartal
</Link>
)}
<button type="button" onClick={clearSelection} disabled={selectedCount === 0}>
</Button>
<Button asChild variant="outline">
{isQuarter ? <Link href={monthHref}>Monatsansicht</Link> : <Link href={quarterHref}>Ganzes Quartal</Link>}
</Button>
<Button type="button" variant="ghost" onClick={clearSelection} disabled={selectedCount === 0}>
Auswahl aufheben
</button>
</Button>
<p className="ml-auto text-sm text-[var(--color-fg-muted)]" aria-live="polite">
Zeitraum: {periodLabel}
</p>
</div>
<p className="billing-period-label" aria-live="polite">
Zeitraum: {periodLabel}
</p>
{positions.length === 0 ? (
<p className="billing-empty">Keine abrechenbaren Nutzungen in diesem Zeitraum.</p>
) : (
<table className="billing-table">
<caption className="billing-caption">
Abrechenbare Nutzungen
</caption>
<thead>
<tr>
<th scope="col">Auswahl</th>
<th scope="col">Datei</th>
<th scope="col">Album</th>
<th scope="col">Zweck</th>
<th scope="col">Referenz</th>
<th scope="col">Preis</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
{positions.map((position) => (
<tr key={position.id} className={position.selectable ? "" : "billing-row-billed"}>
<td>
<input
type="checkbox"
checked={selectedIds.has(position.id)}
onChange={() => togglePosition(position.id)}
disabled={!position.selectable}
<section className="flex flex-col gap-3" aria-labelledby="positions-title">
<h2 id="positions-title" className="text-lg font-semibold">Abrechenbare Nutzungen</h2>
{positions.length === 0 ? (
<EmptyState title="Keine abrechenbaren Nutzungen in diesem Zeitraum." description="Wählen Sie oben einen anderen Monat oder ein Quartal." />
) : (
<Table<BillingPosition>
rowKey={(position) => position.id}
rows={positions}
columns={[
{
key: "id",
header: "Auswahl",
render: (position) => (
<Checkbox
aria-label={`${position.filename} auswählen`}
checked={selectedIds.has(position.id)}
disabled={!position.selectable}
onChange={() => togglePosition(position.id)}
/>
</td>
<td>{position.filename}</td>
<td>{position.albumName}</td>
<td>{position.purpose}</td>
<td>{position.reference ?? "—"}</td>
<td className="billing-price">{formatCents(position.priceCents)}</td>
<td>
<span className="billing-status">
{STATUS_LABELS[position.status]}
),
},
{ key: "filename", header: "Datei" },
{ key: "albumName", header: "Album" },
{ key: "purpose", header: "Zweck" },
{ key: "reference", header: "Referenz", render: (position) => position.reference ?? "—" },
{
key: "priceCents",
header: "Preis",
align: "right",
render: (position) => <span className="tabular-nums">{formatCents(position.priceCents)}</span>,
},
{
key: "status",
header: "Status",
render: (position) => (
<span className="flex flex-wrap items-center gap-2">
<Badge variant={STATUS_BADGES[position.status] ?? "neutral"}>{STATUS_LABELS[position.status]}</Badge>
{position.status === "billed" && position.reportNumber !== null && (
<span className="billing-report-ref">
{" "}· Bericht Nr. {position.reportNumber}
<span className="text-xs text-[var(--color-fg-muted)]">
Bericht Nr. {position.reportNumber}
{position.invoiceNumber ? ` · ${position.invoiceNumber}` : ""}
</span>
)}
</span>
</td>
</tr>
))}
</tbody>
</table>
)}
),
},
]}
/>
)}
</section>
{repeatDownloads.length > 0 && (
<section aria-labelledby="repeat-downloads-title" className="billing-repeat-section">
<h2 id="repeat-downloads-title">Kostenlose Wiederabrufe</h2>
<p className="form-note">
<section aria-labelledby="repeat-downloads-title" className="flex flex-col gap-3">
<h2 id="repeat-downloads-title" className="text-lg font-semibold">Kostenlose Wiederabrufe</h2>
<p className="text-sm text-[var(--color-fg-muted)]">
Wiederholte Downloads rufen bereits abgerechnete Nutzungen erneut ab und sind nicht
abrechenbar.
</p>
<table className="billing-table billing-table-repeat">
<caption className="billing-caption">Wiederabrufe im Zeitraum</caption>
<thead>
<tr>
<th scope="col">Datei</th>
<th scope="col">Datum</th>
<th scope="col">Status</th>
<th scope="col">Notiz</th>
</tr>
</thead>
<tbody>
{repeatDownloads.map((download) => (
<tr key={download.id}>
<td>{download.assetId}</td>
<td>
<time dateTime={download.authorizedAt.toISOString()} suppressHydrationWarning>
{download.authorizedAt.toLocaleDateString("de-DE")}
</time>
</td>
<td>{download.status}</td>
<td>{download.repeatDownloadNote ?? "—"}</td>
</tr>
))}
</tbody>
</table>
<Table<RepeatDownloadPosition>
rowKey={(download) => download.id}
rows={repeatDownloads}
columns={[
{ key: "assetId", header: "Datei" },
{
key: "authorizedAt",
header: "Datum",
render: (download) => (
<time dateTime={download.authorizedAt.toISOString()} suppressHydrationWarning>
{download.authorizedAt.toLocaleDateString("de-DE")}
</time>
),
},
{ key: "status", header: "Status" },
{ key: "repeatDownloadNote", header: "Notiz", render: (download) => download.repeatDownloadNote ?? "—" },
]}
/>
</section>
)}
<div className="billing-summary" aria-live="polite">
<p>
<strong>{selectedCount}</strong> {selectedCount === 1 ? "Nutzung" : "Nutzungen"} ausgewählt
</p>
<p className="billing-summary-total">
Summe: <strong>{formatCents(selectedTotalCents)}</strong>
</p>
</div>
<div className="billing-actions">
<button
type="button"
onClick={handlePreview}
disabled={selectedCount === 0 || actionState.loading}
>
Vorschau
</button>
<button
type="button"
className="billing-action-primary"
onClick={handleFinalize}
disabled={selectedCount === 0 || actionState.loading}
>
Abrechnung erstellen
</button>
</div>
{actionState.message && (
<p className="billing-status-message" role={actionState.isError ? "alert" : "status"}>
{actionState.message}
</p>
)}
<Card>
<div className="flex flex-wrap items-center justify-between gap-4">
<div aria-live="polite" className="billing-summary flex flex-col gap-1">
<p className="text-sm text-[var(--color-fg-muted)]">
<strong className="text-[var(--color-fg-default)]">{selectedCount}</strong> {selectedCount === 1 ? "Nutzung" : "Nutzungen"} ausgewählt
</p>
<p className="text-2xl font-semibold tabular-nums">
Summe: <strong>{formatCents(selectedTotalCents)}</strong>
</p>
</div>
<div className="flex flex-wrap gap-3">
<Button type="button" variant="outline" onClick={handlePreview} disabled={selectedCount === 0 || actionState.loading}>
Vorschau
</Button>
<Button type="button" onClick={handleFinalize} disabled={selectedCount === 0 || actionState.loading}>
Abrechnung erstellen
</Button>
</div>
</div>
{actionState.message && (
<div role={actionState.isError ? undefined : "status"}>
<Alert color={actionState.isError ? "danger" : "info"} description={actionState.message} />
</div>
)}
</Card>
{reports.length > 0 && (
<section aria-labelledby="reports-title" className="billing-reports-section">
<h2 id="reports-title">Erstellte Abrechnungen</h2>
<ul className="billing-reports-list">
<section aria-labelledby="reports-title" className="flex flex-col gap-3">
<h2 id="reports-title" className="text-lg font-semibold">Erstellte Abrechnungen</h2>
<ul className="flex flex-col gap-3">
{reports.map((report) => (
<li key={report.id}>
<div className="billing-report-meta">
<span>Bericht Nr. {report.reportNumber}</span>
{report.invoiceNumber && <span>{report.invoiceNumber}</span>}
<span>Summe: {formatCents(report.netTotalCents)}</span>
<span>Status: {REPORT_STATUS_LABELS[report.status] ?? report.status}</span>
<span>
Erstellt am:{" "}
<time dateTime={report.createdAt.toISOString()} suppressHydrationWarning>
{report.createdAt.toLocaleDateString("de-DE")}
</time>
</span>
</div>
{report.status === "final" && (
<>
<Card>
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 text-sm">
<span className="inline-flex items-center gap-2 font-semibold">
<IconFileText size={16} aria-hidden="true" />
Bericht Nr. {report.reportNumber}
</span>
{report.invoiceNumber && <span>{report.invoiceNumber}</span>}
<span className="tabular-nums">Summe: {formatCents(report.netTotalCents)}</span>
<Badge variant={report.status === "final" ? "success" : "neutral"}>
{REPORT_STATUS_LABELS[report.status] ?? report.status}
</Badge>
<span className="text-[var(--color-fg-muted)]">
Erstellt am:{" "}
<time dateTime={report.createdAt.toISOString()} suppressHydrationWarning>
{report.createdAt.toLocaleDateString("de-DE")}
</time>
</span>
{report.status === "final" && (
<Button asChild variant="outline">
<a className="ml-auto" href={`/api/billing-reports/${encodeURIComponent(report.id)}`} download>
<IconDownload size={16} aria-hidden="true" />
PDF herunterladen
</a>
</Button>
)}
</div>
{report.status === "final" && (
<CancelReportForm reportId={report.id} reportNumber={report.reportNumber} />
<a
href={`/api/billing-reports/${encodeURIComponent(report.id)}`}
className="billing-report-download"
download
>
PDF herunterladen
</a>
</>
)}
)}
</Card>
</li>
))}
</ul>
@@ -364,42 +359,33 @@ function PeriodSelector({ year, month, quarter, isQuarter }: PeriodSelectorProps
const years = [2025, 2026, 2027];
return (
<form className="billing-period-selector" method="get">
<label>
<span>Jahr</span>
<select name="year" defaultValue={year}>
{years.map((y) => (
<option key={y} value={y}>
{y}
</option>
))}
</select>
</label>
{isQuarter ? (
<label>
<span>Quartal</span>
<select name="quarter" defaultValue={quarter ?? 1}>
{[1, 2, 3, 4].map((q) => (
<option key={q} value={q}>
Q{q}
</option>
))}
</select>
</label>
) : (
<label>
<span>Monat</span>
<select name="month" defaultValue={month ?? 8}>
{MONTHS.map((name, index) => (
<option key={index} value={index + 1}>
{name}
</option>
))}
</select>
</label>
)}
<button type="submit">Zeitraum laden</button>
</form>
<Card>
<form className="flex flex-wrap items-end gap-4" method="get">
<div className="w-32">
<FormSelect name="year" label="Jahr" defaultValue={String(year)} options={years.map((y) => ({ label: String(y), value: String(y) }))} />
</div>
{isQuarter ? (
<div className="w-32">
<FormSelect
name="quarter"
label="Quartal"
defaultValue={String(quarter ?? 1)}
options={[1, 2, 3, 4].map((q) => ({ label: `Q${q}`, value: String(q) }))}
/>
</div>
) : (
<div className="w-40">
<FormSelect
name="month"
label="Monat"
defaultValue={String(month ?? 8)}
options={MONTHS.map((name, index) => ({ label: name, value: String(index + 1) }))}
/>
</div>
)}
<Button type="submit" variant="secondary">Zeitraum laden</Button>
</form>
</Card>
);
}
@@ -440,38 +426,28 @@ function CancelReportForm({ reportId, reportNumber }: CancelReportFormProps) {
}
return (
<form className="billing-cancel-form" onSubmit={handleSubmit}>
<label>
<span>Stornierungsgrund (5–500 Zeichen)</span>
<textarea
value={reason}
onChange={(e) => setReason(e.target.value)}
rows={2}
maxLength={500}
<form className="flex flex-col gap-3 border-t border-[var(--color-border-subtle)] pt-4" onSubmit={handleSubmit}>
<Textarea
aria-label={`Stornierungsgrund für Bericht Nr. ${reportNumber}`}
disabled={loading}
label="Stornierungsgrund (5–500 Zeichen)"
maxLength={500}
onChange={(e) => setReason(e.target.value)}
rows={2}
value={reason}
/>
</label>
<div className="billing-cancel-controls">
<label>
<input
type="checkbox"
<div className="flex flex-wrap items-center gap-4">
<Checkbox
checked={confirmed}
onChange={(e) => setConfirmed(e.target.checked)}
disabled={loading}
aria-label="Stornierung bestätigen"
label="Stornierung bestätigen"
onChange={(e) => setConfirmed(e.target.checked)}
/>
<span>Stornierung bestätigen</span>
</label>
<button type="submit" disabled={!valid || loading}>
{loading ? "Wird storniert…" : "Stornieren"}
</button>
</div>
{error && (
<p className="billing-status-message" role="alert">
{error}
</p>
)}
</form>
<Button type="submit" variant="destructive" disabled={!valid || loading}>
{loading ? "Wird storniert …" : "Stornieren"}
</Button>
</div>
{error && <Alert color="danger" description={error} />}
</form>
);
}
}
@@ -1,6 +1,9 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { loadBillingSelection } from "./page-content";
import { BillingSelection } from "./BillingSelection";
@@ -17,12 +20,12 @@ export default async function BillingSelectionPage({
if (!data) notFound();
return (
<section className="content-section" aria-labelledby="billing-selection-title">
<p className="eyebrow">Abrechnungen</p>
<h1 id="billing-selection-title">{data.editorial.name}</h1>
<p>
<Link href="/admin/abrechnungen">Zurück zur Übersicht</Link>
</p>
<section className="flex flex-col gap-6" aria-labelledby="billing-selection-title">
<PageHeader kicker="Abrechnungen" title={data.editorial.name} titleId="billing-selection-title">
<Button asChild variant="outline">
<Link href="/admin/abrechnungen">Zurück zur Übersicht</Link>
</Button>
</PageHeader>
<BillingSelection
editorialId={data.editorial.id}
+35 -17
View File
@@ -1,5 +1,9 @@
import { desc } from "drizzle-orm";
import Link from "next/link";
import { PageHeader } from "@/components/ui/page-header";
import { Badge, Card, EmptyState } from "@/components/ui/sakani";
import { db } from "@/db/client";
import { editorialAccounts } from "@/db/schema";
import { formatCents } from "@/modules/billing/format";
@@ -18,30 +22,44 @@ export default async function BillingOverviewPage() {
.orderBy(desc(editorialAccounts.createdAt));
return (
<section className="content-section" aria-labelledby="billing-title">
<p className="eyebrow">Abrechnungen</p>
<h1 id="billing-title">Redaktionen</h1>
<p className="form-note">
Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für einen Monat oder ein Quartal
auszuwählen.
</p>
<section className="flex flex-col gap-6" aria-labelledby="billing-title">
<PageHeader
kicker="Abrechnungen"
title="Redaktionen"
titleId="billing-title"
description="Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für einen Monat oder ein Quartal auszuwählen."
/>
{editorials.length === 0 ? (
<p>Noch keine Redaktionen registriert.</p>
<EmptyState title="Noch keine Redaktionen registriert." description="Registrierte Redaktionen erscheinen hier zur Abrechnung." />
) : (
<ul className="billing-editorial-list">
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{editorials.map((editorial) => (
<li key={editorial.id}>
<a href={`/admin/abrechnungen/${editorial.id}`}>{editorial.name}</a>
<p>
{editorial.contactName} · {editorial.loginEmail} · Status: {editorial.status}
{editorial.currentPriceCents === null
? " · Preis noch nicht festgelegt"
: ` · Netto ${formatCents(editorial.currentPriceCents)}`}
</p>
<Link
className="block h-full rounded-[var(--radius-xl)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]"
href={`/admin/abrechnungen/${editorial.id}`}
>
<Card interactive className="h-full">
<div className="flex items-start justify-between gap-3">
<h2 className="text-base font-semibold">{editorial.name}</h2>
<Badge variant={editorial.status === "active" ? "success" : editorial.status === "pending_approval" ? "warning" : "danger"}>
{editorial.status === "active" ? "Aktiv" : editorial.status === "pending_approval" ? "Ausstehend" : "Gesperrt"}
</Badge>
</div>
<p className="text-sm text-[var(--color-fg-muted)]">
{editorial.contactName} · {editorial.loginEmail}
</p>
<p className="text-sm font-medium">
{editorial.currentPriceCents === null
? "Preis noch nicht festgelegt"
: `Netto ${formatCents(editorial.currentPriceCents)}`}
</p>
</Card>
</Link>
</li>
))}
</ul>
)}
</section>
);
}
}
+107 -141
View File
@@ -5,9 +5,11 @@
import { useActionState, useMemo, useState, useTransition } from "react";
import Link from "next/link";
import { Alert, 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 { Input } from "@/components/ui/input";
import type { AlbumAccessActionResult } from "./actions";
type AccessAction = (
@@ -15,6 +17,8 @@ type AccessAction = (
formData: FormData,
) => Promise<AlbumAccessActionResult>;
type OverviewRow = AlbumAccessManagerAlbum;
export type AlbumAccessManagerAlbum = {
id: string;
albumName: string;
@@ -154,10 +158,10 @@ export function AlbumAccessManager({
})`;
return (
<div className="space-y-8">
<div className="flex flex-col gap-6">
<Card>
<CardHeader>
<CardTitle className="text-lg">Bulk-Zuweisung</CardTitle>
<CardTitle>Bulk-Zuweisung</CardTitle>
<CardDescription>
Alben und Redaktionen auswählen und allen ausgewählten Redaktionen mit einem Klick
Zugriff auf alle ausgewählten Alben geben. Bereits bestehende Zuweisungen werden
@@ -165,14 +169,15 @@ export function AlbumAccessManager({
</CardDescription>
</CardHeader>
<CardContent>
<form action={handleBulkSubmit} className="space-y-6">
<form action={handleBulkSubmit} className="flex flex-col gap-6">
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
<fieldset className="space-y-3 min-w-0">
<legend className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
<fieldset className="flex min-w-0 flex-col gap-3">
<legend className="mb-3 text-sm font-medium text-[var(--color-fg-muted)]">
Alben ({selectedAlbumIds.size} ausgewählt)
</legend>
<div className="flex flex-col sm:flex-row gap-2">
<Input
leadingIcon={<IconSearch size={16} />}
type="search"
value={bulkSearch}
onChange={(event) => setBulkSearch(event.target.value)}
@@ -190,37 +195,30 @@ export function AlbumAccessManager({
{allBulkAlbumsSelected ? "Auswahl aufheben" : "Alle auswählen"}
</Button>
</div>
<div className="max-h-80 overflow-y-auto rounded-md border border-border divide-y divide-border">
<div className="max-h-80 divide-y divide-[var(--color-border-subtle)] overflow-y-auto rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
{bulkAlbums.length === 0 ? (
<p className="p-4 text-sm text-muted-foreground">Keine Alben gefunden.</p>
<p className="p-4 text-sm text-[var(--color-fg-muted)]">Keine Alben gefunden.</p>
) : (
bulkAlbums.map((album) => (
<label
key={album.id}
className="flex items-center gap-3 px-4 py-2.5 text-sm cursor-pointer hover:bg-accent/50"
>
<input
type="checkbox"
name="immichAlbumIds"
value={album.id}
<div key={album.id} className="flex items-center gap-3 px-4 py-2.5 hover:bg-[var(--color-bg-subtle)]">
<Checkbox
checked={selectedAlbumIds.has(album.id)}
onChange={(event) =>
toggleAlbumSelection(album.id, event.target.checked)
}
className="h-4 w-4 accent-primary-600"
label={album.albumName}
name="immichAlbumIds"
onChange={(event) => toggleAlbumSelection(album.id, event.target.checked)}
value={album.id}
/>
<span className="truncate font-medium">{album.albumName}</span>
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
<span className="ml-auto shrink-0 text-xs text-[var(--color-fg-muted)]">
{album.assetCount} Fotos
</span>
</label>
</div>
))
)}
</div>
</fieldset>
<fieldset className="space-y-3 min-w-0">
<legend className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">
<fieldset className="flex min-w-0 flex-col gap-3">
<legend className="mb-3 text-sm font-medium text-[var(--color-fg-muted)]">
Redaktionen ({selectedEditorialIds.size} ausgewählt)
</legend>
<div className="flex justify-end">
@@ -234,29 +232,22 @@ export function AlbumAccessManager({
{allEditorialsSelected ? "Auswahl aufheben" : "Alle auswählen"}
</Button>
</div>
<div className="max-h-80 overflow-y-auto rounded-md border border-border divide-y divide-border">
<div className="max-h-80 divide-y divide-[var(--color-border-subtle)] overflow-y-auto rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
{editorials.length === 0 ? (
<p className="p-4 text-sm text-muted-foreground">
<p className="p-4 text-sm text-[var(--color-fg-muted)]">
Keine aktiven Redaktionen vorhanden.
</p>
) : (
editorials.map((editorial) => (
<label
key={editorial.id}
className="flex items-center gap-3 px-4 py-2.5 text-sm cursor-pointer hover:bg-accent/50"
>
<input
type="checkbox"
name="editorialIds"
value={editorial.id}
<div key={editorial.id} className="px-4 py-2.5 hover:bg-[var(--color-bg-subtle)]">
<Checkbox
checked={selectedEditorialIds.has(editorial.id)}
onChange={(event) =>
toggleEditorialSelection(editorial.id, event.target.checked)
}
className="h-4 w-4 accent-primary-600"
label={editorial.name}
name="editorialIds"
onChange={(event) => toggleEditorialSelection(editorial.id, event.target.checked)}
value={editorial.id}
/>
<span className="truncate font-medium">{editorial.name}</span>
</label>
</div>
))
)}
</div>
@@ -265,16 +256,9 @@ export function AlbumAccessManager({
<div className="flex flex-col sm:flex-row sm:items-center gap-3 sm:justify-between">
{bulkState.message ? (
<p
role={bulkState.ok ? "status" : "alert"}
className={`text-sm ${
bulkState.ok ? "text-green-700 dark:text-green-400" : "text-destructive"
}`}
>
{bulkState.message}
</p>
<Alert color={bulkState.ok ? "success" : "danger"} description={bulkState.message} />
) : (
<p className="text-sm text-muted-foreground">
<p className="text-sm text-[var(--color-fg-muted)]">
Wähle mindestens ein Album und eine Redaktion aus.
</p>
)}
@@ -289,7 +273,7 @@ export function AlbumAccessManager({
<Card>
<CardHeader className="gap-4">
<div>
<CardTitle className="text-lg">Albumzugriffe</CardTitle>
<CardTitle>Albumzugriffe</CardTitle>
<CardDescription>
Welche Redaktionen Zugriff auf welches Album hat. Ein Klick auf das × entzieht den
Zugriff für die einzelne Redaktion.
@@ -297,6 +281,7 @@ export function AlbumAccessManager({
</div>
<div className="sm:max-w-sm">
<Input
leadingIcon={<IconSearch size={16} />}
type="search"
value={overviewSearch}
onChange={(event) => setOverviewSearch(event.target.value)}
@@ -305,103 +290,84 @@ export function AlbumAccessManager({
/>
</div>
</CardHeader>
<CardContent className="space-y-4">
<CardContent className="flex flex-col gap-4">
{revokeState.message ? (
<p
role={revokeState.ok ? "status" : "alert"}
className={`text-sm ${
revokeState.ok ? "text-green-700 dark:text-green-400" : "text-destructive"
}`}
>
{revokeState.message}
</p>
<Alert color={revokeState.ok ? "success" : "danger"} description={revokeState.message} />
) : null}
{albums.length === 0 ? (
<p className="text-muted-foreground text-sm">Derzeit sind keine Alben vorhanden.</p>
<EmptyState title="Derzeit sind keine Alben vorhanden." description="Alben erscheinen hier, sobald der Immich-Zugang sie lesen kann." />
) : overviewAlbums.length === 0 ? (
<p className="text-muted-foreground text-sm">Keine Alben gefunden.</p>
<EmptyState type="no-results" title="Keine Alben gefunden." description="Versuchen Sie einen anderen Suchbegriff." />
) : (
<div className="overflow-x-auto rounded-md border border-border">
<table className="w-full text-left text-sm">
<thead className="bg-muted/50 border-b border-border">
<tr>
<th className="py-3 px-4 font-semibold">Album</th>
<th className="py-3 px-4 font-semibold">Redaktionen mit Zugriff</th>
<th className="py-3 px-4 font-semibold text-right">Anzahl</th>
</tr>
</thead>
<tbody>
{overviewAlbums.map((album, index) => (
<tr
key={album.id}
className={index !== overviewAlbums.length - 1 ? "border-b border-border" : ""}
>
<td className="py-3 px-4">
<div className="flex items-center gap-3">
{album.albumThumbnailAssetId ? (
<img
className="h-10 w-14 rounded object-cover bg-muted shrink-0"
alt=""
loading="lazy"
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
/>
) : (
<div
aria-hidden="true"
className="h-10 w-14 rounded bg-muted shrink-0 flex items-center justify-center text-[10px] uppercase tracking-widest text-muted-foreground"
>
Kein Cover
</div>
)}
<div className="min-w-0">
<p className="font-medium truncate" title={album.albumName}>
{album.albumName}
</p>
<p className="text-xs text-muted-foreground">{album.assetCount} Fotos</p>
</div>
<Table<OverviewRow>
rowKey={(album) => album.id}
rows={overviewAlbums}
columns={[
{
key: "albumName",
header: "Album",
render: (album) => (
<div className="flex items-center gap-3">
{album.albumThumbnailAssetId ? (
<img
className="h-10 w-14 shrink-0 rounded-[var(--radius-sm)] bg-[var(--color-bg-subtle)] object-cover"
alt=""
loading="lazy"
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
/>
) : (
<div aria-hidden="true" className="grid h-10 w-14 shrink-0 place-items-center rounded-[var(--radius-sm)] bg-[var(--color-bg-subtle)] text-[10px] text-[var(--color-fg-muted)]">
Kein Cover
</div>
</td>
<td className="py-3 px-4">
{album.grants.length === 0 ? (
<span className="text-muted-foreground">Noch keine Redaktion</span>
) : (
<div className="flex flex-wrap gap-1.5">
{album.grants.map((holder) => (
<form
key={holder.editorialId}
action={revokeFormAction}
className="inline-flex items-center overflow-hidden rounded-full border border-primary-200 bg-primary-50 text-primary-700 dark:border-primary-800 dark:bg-primary-900/30 dark:text-primary-300"
>
<input type="hidden" name="immichAlbumId" value={album.id} />
<input type="hidden" name="editorialId" value={holder.editorialId} />
<Link
href={`/admin/redaktionen/${holder.editorialId}`}
className="py-0.5 pl-2.5 text-xs font-medium hover:underline"
>
{holder.editorialName}
{holder.archived ? " (archiviert)" : ""}
</Link>
<button
type="submit"
disabled={revokePending}
aria-label={`Zugriff auf ${album.albumName} für ${holder.editorialName} entziehen`}
title={`Zugriff für ${holder.editorialName} entziehen`}
className="px-2 py-0.5 text-xs font-bold hover:bg-primary-100 dark:hover:bg-primary-800/50 disabled:opacity-50"
>
×
</button>
</form>
))}
</div>
)}
</td>
<td className="py-3 px-4 text-right tabular-nums">{album.grants.length}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<div className="min-w-0">
<p className="truncate font-medium" title={album.albumName}>{album.albumName}</p>
<p className="text-xs text-[var(--color-fg-muted)]">{album.assetCount} Fotos</p>
</div>
</div>
),
},
{
key: "grants",
header: "Redaktionen mit Zugriff",
render: (album) =>
album.grants.length === 0 ? (
<span className="text-[var(--color-fg-muted)]">Noch keine Redaktion</span>
) : (
<div className="flex flex-wrap gap-1.5">
{album.grants.map((holder) => (
<form
key={holder.editorialId}
action={revokeFormAction}
className="inline-flex items-center overflow-hidden rounded-[var(--radius-full)] border border-[var(--color-border-default)] bg-[var(--color-bg-subtle)] text-[var(--color-fg-default)]"
>
<input type="hidden" name="immichAlbumId" value={album.id} />
<input type="hidden" name="editorialId" value={holder.editorialId} />
<Link
href={`/admin/redaktionen/${holder.editorialId}`}
className="py-0.5 pl-2.5 text-xs font-medium hover:underline"
>
{holder.editorialName}
{holder.archived ? " (archiviert)" : ""}
</Link>
<button
type="submit"
disabled={revokePending}
aria-label={`Zugriff auf ${album.albumName} für ${holder.editorialName} entziehen`}
title={`Zugriff für ${holder.editorialName} entziehen`}
className="grid place-items-center px-1.5 py-1 hover:bg-[var(--color-bg-muted)] disabled:opacity-50"
>
<IconX size={12} aria-hidden="true" />
</button>
</form>
))}
</div>
),
},
{ key: "assetCount", header: "Anzahl", align: "right", render: (album) => <span className="tabular-nums">{album.grants.length}</span> },
]}
/>
)}
</CardContent>
</Card>
+13 -16
View File
@@ -1,6 +1,8 @@
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { Alert } from "@/components/ui/sakani";
import { loadAlbumAccess, loadAssignableEditorials } from "./page-content";
import { AlbumAccessManager } from "./AlbumAccessManager";
@@ -13,21 +15,22 @@ export default async function AdminAlbumsPage() {
]);
return (
<div className="space-y-8 max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<section className="flex flex-col gap-6">
<PageHeader
kicker="Albumverwaltung"
title="Alben"
description="Alle Immich-Alben mit ihren Redaktionsfreigaben — inklusive Bulk-Zuweisung für mehrere Alben und Redaktionen auf einmal."
/>
>
<Button asChild variant="outline">
<Link href="/admin/redaktionen">Zu den Redaktionen</Link>
</Button>
</PageHeader>
{albumResult.unavailable ? (
<div
className="bg-destructive/15 text-destructive p-4 rounded-md border border-destructive/30"
role="status"
>
Die Immich-Alben sind momentan nicht erreichbar. Bereits bestehende Zuweisungen bleiben
unverändert.
</div>
<Alert
color="warning"
description="Die Immich-Alben sind momentan nicht erreichbar. Bereits bestehende Zuweisungen bleiben unverändert."
/>
) : (
<AlbumAccessManager
albums={albumResult.albums.map((album) => ({
@@ -46,12 +49,6 @@ export default async function AdminAlbumsPage() {
revokeAction={revokeAlbumAccessAction}
/>
)}
<p className="text-sm">
<Link href="/admin/redaktionen" className="text-primary-600 hover:underline">
Zu den Redaktionen
</Link>
</p>
</div>
</section>
);
}
+42 -58
View File
@@ -1,5 +1,8 @@
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 { listAuditEvents, type AuditEventRow } from "@/modules/audit/queries";
import { requireAdminPage } from "../access";
@@ -31,71 +34,52 @@ export default async function AuditPage({ searchParams }: { searchParams: Search
);
return (
<section className="content-section" aria-labelledby="audit-title">
<p className="eyebrow">Administration</p>
<h1 id="audit-title">Audit-Protokoll</h1>
<p className="form-note">
Chronologische Aufzeichnung aller sicherheitsrelevanten Vorgänge. Sortierung fest nach
Zeitstempel (neueste zuerst).
</p>
<section className="flex flex-col gap-6" aria-labelledby="audit-title">
<PageHeader
kicker="Administration"
title="Audit-Protokoll"
titleId="audit-title"
description="Chronologische Aufzeichnung aller sicherheitsrelevanten Vorgänge. Sortierung fest nach Zeitstempel (neueste zuerst)."
/>
<form method="get" className="audit-filters" aria-label="Audit-Filter">
<label>
<span className="field-label">Ereignistyp</span>
<input
name="eventType"
defaultValue={eventType ?? ""}
placeholder="z. B. editorial_approved"
/>
</label>
<label>
<span className="field-label">Datum von (Berlin)</span>
<input type="date" name="dateFrom" defaultValue={dateFrom ?? ""} />
</label>
<label>
<span className="field-label">Datum bis (Berlin)</span>
<input type="date" name="dateTo" defaultValue={dateTo ?? ""} />
</label>
<button type="submit">Filtern</button>
</form>
<Card>
<form method="get" className="grid gap-4 sm:grid-cols-[1fr_11rem_11rem_auto] sm:items-end" aria-label="Audit-Filter">
<Input label="Ereignistyp" name="eventType" defaultValue={eventType ?? ""} placeholder="z. B. editorial_approved" />
<Input label="Datum von (Berlin)" type="date" name="dateFrom" defaultValue={dateFrom ?? ""} />
<Input label="Datum bis (Berlin)" type="date" name="dateTo" defaultValue={dateTo ?? ""} />
<Button type="submit" variant="secondary">Filtern</Button>
</form>
</Card>
{page.events.length === 0 ? (
<p>Keine Einträge gefunden.</p>
<EmptyState type="no-results" title="Keine Einträge gefunden." description="Passen Sie die Filter an oder setzen Sie sie zurück." />
) : (
<table className="audit-table">
<thead>
<tr>
<th>Zeitstempel</th>
<th>Akteur</th>
<th>Ereignistyp</th>
<th>Betreff</th>
<th>Details</th>
</tr>
</thead>
<tbody>
{page.events.map((event) => (
<tr key={event.id}>
<td>{berlinFormatter.format(new Date(event.occurredAt))}</td>
<td>{actorLabel(event)}</td>
<td>{event.eventType}</td>
<td>{entityLabel(event)}</td>
<td>
<pre className="audit-metadata">{formatMetadata(event)}</pre>
</td>
</tr>
))}
</tbody>
</table>
<DataTable
columns={[
{ key: "at", header: "Zeitstempel" },
{ key: "actor", header: "Akteur" },
{ key: "type", header: "Ereignistyp" },
{ key: "subject", header: "Betreff" },
{ key: "details", header: "Details" },
]}
rows={page.events.map((event) => ({
at: <span className="whitespace-nowrap tabular-nums">{berlinFormatter.format(new Date(event.occurredAt))}</span>,
actor: actorLabel(event),
type: <code className="break-all text-xs">{event.eventType}</code>,
subject: <span className="break-all text-xs">{entityLabel(event)}</span>,
details: <pre className="audit-metadata">{formatMetadata(event)}</pre>,
}))}
/>
)}
{page.nextCursor && (
<p className="audit-pagination">
<Link
href={`/admin/audit?${buildPaginationHref({ eventType, dateFrom, dateTo, cursor: page.nextCursor })}`}
>
Ältere Einträge laden
</Link>
</p>
<div>
<Button asChild variant="outline">
<Link href={`/admin/audit?${buildPaginationHref({ eventType, dateFrom, dateTo, cursor: page.nextCursor })}`}>
Ältere Einträge laden
</Link>
</Button>
</div>
)}
</section>
);
-10
View File
@@ -1,10 +0,0 @@
"use client";
import dynamic from "next/dynamic";
const DownloadsChart = dynamic(
() => import("./downloads-chart").then((mod) => mod.DownloadsChart),
{ ssr: false }
);
export { DownloadsChart };
-80
View File
@@ -1,80 +0,0 @@
"use client";
import { useTheme } from "next-themes";
import {
Bar,
BarChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
CartesianGrid,
} from "recharts";
type DownloadsChartProps = {
data: { date: string; downloads: number }[];
};
export function DownloadsChart({ data }: DownloadsChartProps) {
const { theme } = useTheme();
// Indigo primary color variables
const primaryColor = theme === "dark" ? "#6366f1" : "#4f46e5"; // indigo-500 : indigo-600
return (
<div className="h-[300px] w-full mt-4">
{data.length === 0 ? (
<div className="flex h-full items-center justify-center text-muted-foreground">
Keine Download-Daten in den letzten 30 Tagen verfügbar.
</div>
) : (
<ResponsiveContainer width="100%" height="100%">
<BarChart data={data} margin={{ top: 10, right: 10, left: -20, bottom: 0 }}>
<CartesianGrid strokeDasharray="3 3" vertical={false} stroke={theme === "dark" ? "#333" : "#e5e5e5"} />
<XAxis
dataKey="date"
stroke="#888888"
fontSize={12}
tickLine={false}
axisLine={false}
tickFormatter={(value) => {
const date = new Date(value);
return date.toLocaleDateString("de-DE", { day: "2-digit", month: "short" });
}}
/>
<YAxis
stroke="#888888"
fontSize={12}
tickLine={false}
axisLine={false}
tickFormatter={(value) => `${value}`}
allowDecimals={false}
/>
<Tooltip
cursor={{ fill: theme === "dark" ? "#ffffff10" : "#00000005" }}
contentStyle={{
backgroundColor: theme === "dark" ? "#1f2937" : "#ffffff",
borderColor: theme === "dark" ? "#374151" : "#e5e7eb",
borderRadius: "8px",
color: theme === "dark" ? "#f3f4f6" : "#111827",
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
}}
labelFormatter={(label: any) => {
const date = new Date(label as string);
return date.toLocaleDateString("de-DE", { weekday: 'long', day: '2-digit', month: 'long', year: 'numeric' });
}}
formatter={(value: any) => [value as number, "Downloads"]}
/>
<Bar
dataKey="downloads"
fill={primaryColor}
radius={[4, 4, 0, 0]}
maxBarSize={40}
animationDuration={1000}
/>
</BarChart>
</ResponsiveContainer>
)}
</div>
);
}
+35 -46
View File
@@ -2,8 +2,11 @@
import { useId, useState, useTransition } from "react";
import { Alert, Input, Textarea } from "@sakaniui/react";
import { Card } from "@/components/ui/sakani";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import type { AnnouncementActionResult } from "./actions";
@@ -36,56 +39,42 @@ export function AnnouncementForm({
};
return (
<form
action={handleSubmit}
className="bg-card p-4 rounded-xl border border-border shadow-sm space-y-4"
>
<div className="space-y-2">
<label htmlFor={messageId} className="text-sm font-medium">
Nachricht
</label>
<textarea
<Card title="Neuer Hinweis">
<form action={handleSubmit} className="flex flex-col gap-4">
<Textarea
description={`${message.length}/500 Zeichen`}
id={messageId}
name="message"
rows={3}
label="Nachricht"
maxLength={500}
required
value={message}
name="message"
onChange={(event) => setMessage(event.target.value)}
placeholder="z. B. Liebl ist heute beim HSV-Spiel — Freigaben und Downloads sind trotzdem verfügbar, Antworten dauern etwas länger."
className="flex w-full rounded-md border border-border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
/>
<p className="text-xs text-muted-foreground">{message.length}/500 Zeichen</p>
</div>
<div className="space-y-2">
<label htmlFor={dateId} className="text-sm font-medium">
Datum des Ereignisses (z. B. Spieltag)
</label>
<Input
id={dateId}
type="date"
name="eventDate"
defaultValue={defaultEventDate}
required
className="sm:w-48"
rows={3}
value={message}
/>
<p className="text-xs text-muted-foreground">
Der Hinweis wird sofort sichtbar und verschwindet automatisch drei Tage nach diesem
Datum.
</p>
</div>
<Button type="submit" disabled={pending}>
{pending ? "Wird veröffentlicht…" : "Hinweis veröffentlichen"}
</Button>
{state.message ? (
<p
role="status"
aria-live="polite"
className={state.ok ? "text-sm text-green-600 dark:text-green-400" : "text-sm text-destructive"}
>
{state.message}
</p>
) : null}
</form>
<div className="sm:max-w-xs">
<Input
defaultValue={defaultEventDate}
description="Der Hinweis wird sofort sichtbar und verschwindet automatisch drei Tage nach diesem Datum."
id={dateId}
label="Datum des Ereignisses (z. B. Spieltag)"
name="eventDate"
required
type="date"
/>
</div>
<div>
<Button type="submit" disabled={pending}>
{pending ? "Wird veröffentlicht …" : "Hinweis veröffentlichen"}
</Button>
</div>
{state.message ? (
<div aria-live="polite">
<Alert color={state.ok ? "success" : "danger"} description={state.message} />
</div>
) : null}
</form>
</Card>
);
}
@@ -2,6 +2,8 @@
import { useActionState } from "react";
import { IconTrash } from "@sakaniui/react/icons";
import { Button } from "@/components/ui/button";
import type { AnnouncementActionResult } from "./actions";
@@ -23,11 +25,11 @@ export function DeleteAnnouncementButton({
return (
<form action={formAction} className="flex flex-col items-end gap-1">
<input type="hidden" name="announcementId" value={announcementId} />
<Button type="submit" variant="outline" size="sm" disabled={pending}>
<Button type="submit" variant="ghost" size="sm" disabled={pending} leftIcon={<IconTrash size={16} />}>
{pending ? "…" : "Löschen"}
</Button>
{state.ok ? null : (
<p role="alert" className="text-xs text-destructive">
<p role="alert" className="text-xs text-[var(--color-danger-fg)]">
{state.message}
</p>
)}
+25 -27
View File
@@ -1,4 +1,5 @@
import { PageHeader } from "@/components/ui/page-header";
import { Badge, Card, EmptyState } from "@/components/ui/sakani";
import {
formatIsoDateGerman,
isoDateInBerlin,
@@ -14,7 +15,7 @@ export default async function AdminAnnouncementsPage() {
const activeCount = items.filter((item) => item.isActive).length;
return (
<div className="space-y-8 max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<section className="flex flex-col gap-6">
<PageHeader
kicker="Kommunikation"
title="Hinweise"
@@ -26,46 +27,43 @@ export default async function AdminAnnouncementsPage() {
defaultEventDate={isoDateInBerlin(new Date())}
/>
<section className="space-y-4" aria-labelledby="announcements-list-title">
<div className="flex items-baseline justify-between">
<section className="flex flex-col gap-4" aria-labelledby="announcements-list-title">
<div className="flex items-baseline justify-between gap-4">
<h2 id="announcements-list-title" className="text-xl font-semibold">
Alle Hinweise
</h2>
<p className="text-sm text-muted-foreground">
<p className="text-sm text-[var(--color-fg-muted)]">
{activeCount} aktiv · {items.length} insgesamt
</p>
</div>
{items.length === 0 ? (
<p className="text-muted-foreground py-8 text-center">
Noch keine Hinweise vorhanden.
</p>
<EmptyState title="Noch keine Hinweise vorhanden." description="Veröffentlichte Hinweise erscheinen hier und in der Album-Übersicht der Redaktionen." />
) : (
<ul className="space-y-3">
<ul className="flex flex-col gap-3">
{items.map((item) => (
<li
key={item.id}
className="bg-card p-4 rounded-xl border border-border shadow-sm flex flex-col sm:flex-row sm:items-start gap-4 justify-between"
>
<div className="space-y-1 min-w-0">
<p className="text-sm whitespace-pre-line break-words">{item.message}</p>
<p className="text-xs text-muted-foreground">
Ereignis: {formatIsoDateGerman(item.eventDate)} ·{" "}
{item.isActive ? (
<span className="text-green-600 dark:text-green-400">
sichtbar bis {formatIsoDateGerman(item.visibleUntil)}
</span>
) : (
<span>abgelaufen (war sichtbar bis {formatIsoDateGerman(item.visibleUntil)})</span>
)}
</p>
</div>
<DeleteAnnouncementButton action={deleteAnnouncementAction} announcementId={item.id} />
<li key={item.id}>
<Card>
<div className="flex flex-col justify-between gap-4 sm:flex-row sm:items-start">
<div className="flex min-w-0 flex-col gap-2">
<p className="whitespace-pre-line break-words text-sm text-[var(--color-fg-default)]">{item.message}</p>
<p className="flex flex-wrap items-center gap-2 text-xs text-[var(--color-fg-muted)]">
Ereignis: {formatIsoDateGerman(item.eventDate)}
{item.isActive ? (
<Badge variant="success">sichtbar bis {formatIsoDateGerman(item.visibleUntil)}</Badge>
) : (
<Badge>abgelaufen (war sichtbar bis {formatIsoDateGerman(item.visibleUntil)})</Badge>
)}
</p>
</div>
<DeleteAnnouncementButton action={deleteAnnouncementAction} announcementId={item.id} />
</div>
</Card>
</li>
))}
</ul>
)}
</section>
</div>
</section>
);
}
+6 -14
View File
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import { PortalShell } from "@/components/layout/portal-shell";
import { AppShell } from "@/components/layout/app-shell";
import { env } from "@/config/env";
import { requireAdminPage } from "./access";
@@ -8,20 +9,11 @@ export default async function AdminLayout({ children }: Readonly<{ children: Rea
await requireAdminPage();
return (
<PortalShell
brandHref="/admin"
sectionLabel="Administration"
nav={[
{ href: "/admin", label: "Dashboard" },
{ href: "/admin/redaktionen", label: "Redaktionen" },
{ href: "/admin/alben", label: "Alben" },
{ href: "/admin/hinweise", label: "Hinweise" },
{ href: "/admin/abrechnungen", label: "Abrechnungen" },
{ href: "/admin/audit", label: "Audit" },
]}
mainClassName=""
<AppShell
area="admin"
legal={{ imprint: env.LEGAL_IMPRINT_URL, privacy: env.LEGAL_PRIVACY_URL, terms: env.LEGAL_TERMS_URL }}
>
{children}
</PortalShell>
</AppShell>
);
}
+60 -104
View File
@@ -3,10 +3,9 @@ import { db } from "@/db/client";
import { usages, editorialAccounts } from "@/db/schema";
import Link from "next/link";
import { PageHeader } from "@/components/ui/page-header";
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { BarChart, Card, EmptyState, StatCard, DataTable } from "@/components/ui/sakani";
import { requireAdminPage } from "./access";
import { DownloadsChart } from "./downloads-chart-lazy";
export default async function AdminDashboardPage() {
await requireAdminPage();
@@ -74,125 +73,82 @@ export default async function AdminDashboardPage() {
const dateStr = d.toISOString().split('T')[0];
const record = dailyDownloads.find(r => r.date === dateStr);
chartData.push({
date: dateStr,
downloads: record ? record.downloads : 0,
label: d.toLocaleDateString("de-DE", { day: "numeric" }), // ponytail: day only; 30 "dd. MMM" labels overlap
value: record ? record.downloads : 0,
});
}
const formatter = new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" });
return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500">
<section className="flex flex-col gap-6">
<PageHeader
title="Admin Dashboard"
description="Willkommen zurück! Hier ist ein Überblick über die aktuelle Nutzung des Portals."
/>
>
<Button asChild>
<Link href="/admin/redaktionen">Redaktionen verwalten</Link>
</Button>
</PageHeader>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<Card>
<CardHeader className="pb-2">
<CardTitle className="text-sm font-medium uppercase tracking-wide text-muted-foreground">Umsatz diesen Monat</CardTitle>
</CardHeader>
<CardContent>
<div className="text-4xl font-bold text-primary-600 dark:text-primary-500">
{formatter.format((revenueStats?.totalCents ?? 0) / 100)}
</div>
<p className="text-sm text-muted-foreground mt-1">
{revenueStats?.count ?? 0} lizenzierte Bilder im {now.toLocaleString("de-DE", { month: "long" })}
</p>
</CardContent>
</Card>
<Card className="flex flex-col justify-center items-center bg-primary-50/50 dark:bg-primary-900/10 border-primary-100 dark:border-primary-900/30">
<CardContent className="pt-6">
<Button asChild size="lg" className="w-full">
<Link href="/admin/redaktionen">
Redaktionen verwalten
</Link>
</Button>
</CardContent>
</Card>
<div className="grid grid-cols-1 gap-4 md:grid-cols-3">
<StatCard
title="Umsatz diesen Monat"
value={formatter.format((revenueStats?.totalCents ?? 0) / 100)}
description={`${revenueStats?.count ?? 0} lizenzierte Bilder im ${now.toLocaleString("de-DE", { month: "long" })}`}
/>
</div>
<Card>
<CardHeader>
<CardTitle>Downloads der letzten 30 Tage</CardTitle>
<CardDescription>Tägliche Nutzung des Bildarchivs über alle Redaktionen hinweg.</CardDescription>
</CardHeader>
<CardContent>
<DownloadsChart data={chartData} />
</CardContent>
<Card title="Downloads der letzten 30 Tage" description="Tägliche Nutzung des Bildarchivs über alle Redaktionen hinweg.">
{chartData.every((day) => day.value === 0) ? (
<EmptyState title="Keine Downloads" description="In den letzten 30 Tagen wurden keine Bilder geladen." />
) : (
<BarChart data={chartData} seriesLabels={["Downloads"]} size="lg" />
)}
</Card>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
<Card>
<CardHeader>
<CardTitle>Aktivste Redaktionen</CardTitle>
<CardDescription>Die Top 5 Redaktionen nach Downloads.</CardDescription>
</CardHeader>
<CardContent>
{topEditorials.length === 0 ? (
<p className="text-muted-foreground text-sm">Noch keine Daten vorhanden.</p>
) : (
<div className="overflow-hidden rounded-md border border-border">
<table className="w-full text-left text-sm">
<thead className="bg-muted/50 border-b border-border">
<tr>
<th className="py-3 px-4 font-semibold">Redaktion</th>
<th className="py-3 px-4 font-semibold text-right">Downloads</th>
<th className="py-3 px-4 font-semibold text-right">Umsatz</th>
</tr>
</thead>
<tbody>
{topEditorials.map((ed, i) => (
<tr key={ed.editorialId} className={i !== topEditorials.length - 1 ? "border-b border-border" : ""}>
<td className="py-3 px-4">
<Link href={`/admin/redaktionen/${ed.editorialId}`} className="text-primary-600 dark:text-primary-400 hover:underline font-medium">
{ed.name}
</Link>
</td>
<td className="py-3 px-4 text-right tabular-nums">{ed.downloadCount}</td>
<td className="py-3 px-4 text-right tabular-nums">{formatter.format(ed.revenueCents / 100)}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</CardContent>
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
<Card title="Aktivste Redaktionen" description="Die Top 5 Redaktionen nach Downloads.">
{topEditorials.length === 0 ? (
<EmptyState title="Noch keine Daten vorhanden." description="Sobald Bilder geladen werden, erscheint hier die Auswertung." />
) : (
<DataTable
columns={[
{ key: "name", header: "Redaktion" },
{ key: "downloads", header: "Downloads", align: "right" },
{ key: "revenue", header: "Umsatz", align: "right" },
]}
rows={topEditorials.map((ed) => ({
id: ed.editorialId,
name: (
<Link href={`/admin/redaktionen/${ed.editorialId}`} className="font-medium text-[var(--color-brand-fg)] hover:underline">
{ed.name}
</Link>
),
downloads: <span className="tabular-nums">{ed.downloadCount}</span>,
revenue: <span className="tabular-nums">{formatter.format(ed.revenueCents / 100)}</span>,
}))}
/>
)}
</Card>
<Card>
<CardHeader>
<CardTitle>Beliebteste Alben</CardTitle>
<CardDescription>Die Top 5 Alben nach Nutzung.</CardDescription>
</CardHeader>
<CardContent>
{topAlbums.length === 0 ? (
<p className="text-muted-foreground text-sm">Noch keine Daten vorhanden.</p>
) : (
<div className="overflow-hidden rounded-md border border-border">
<table className="w-full text-left text-sm">
<thead className="bg-muted/50 border-b border-border">
<tr>
<th className="py-3 px-4 font-semibold">Album</th>
<th className="py-3 px-4 font-semibold text-right">Downloads</th>
</tr>
</thead>
<tbody>
{topAlbums.map((album, i) => (
<tr key={album.albumName} className={i !== topAlbums.length - 1 ? "border-b border-border" : ""}>
<td className="py-3 px-4 font-medium">{album.albumName}</td>
<td className="py-3 px-4 text-right tabular-nums">{album.downloadCount}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</CardContent>
<Card title="Beliebteste Alben" description="Die Top 5 Alben nach Nutzung.">
{topAlbums.length === 0 ? (
<EmptyState title="Noch keine Daten vorhanden." description="Sobald Bilder geladen werden, erscheint hier die Auswertung." />
) : (
<DataTable
columns={[
{ key: "albumName", header: "Album" },
{ key: "downloads", header: "Downloads", align: "right" },
]}
rows={topAlbums.map((album) => ({
albumName: album.albumName,
downloads: <span className="tabular-nums">{album.downloadCount}</span>,
}))}
/>
)}
</Card>
</div>
</div>
</section>
);
}
@@ -3,6 +3,10 @@
/* eslint-disable @next/next/no-img-element */
import { useState, useTransition } from "react";
import { Badge, Button, EmptyState, Input } from "@sakaniui/react";
import { IconMail, IconSearch } from "@sakaniui/react/icons";
import { Card } from "@/components/ui/sakani";
import type { AlbumActionResult } from "./actions";
@@ -49,75 +53,69 @@ function AlbumCard({ album, editorialId, grantAction, revokeAction, notifyAction
});
};
const notifyLabel =
notifyStatus === "pending" ? "Wird gesendet …" :
notifyStatus === "success" ? "E-Mail gesendet!" :
notifyStatus === "error" ? "Fehler beim Senden" :
"Redaktion benachrichtigen";
return (
<li className={`flex flex-col bg-white border ${album.isGranted ? 'border-green-500 shadow-md ring-1 ring-green-500' : 'border-gray-200'} rounded-xl overflow-hidden transition-all duration-300 hover:shadow-lg`} data-granted={album.isGranted}>
<div className="relative aspect-[3/2] bg-gray-100 overflow-hidden">
{album.albumThumbnailAssetId ? (
<img
className="w-full h-full object-contain transition-transform duration-500 hover:scale-105"
alt={`Titelbild von ${album.albumName}`}
loading="lazy"
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
/>
) : (
<div aria-label="Kein Albumcover verfügbar" className="w-full h-full flex items-center justify-center text-gray-400 text-xs uppercase tracking-widest" role="img">
Kein Cover
</div>
)}
{album.isGranted && (
<div className="absolute top-2 right-2 bg-green-500 text-white text-xs font-bold px-2 py-1 rounded-full shadow-sm">
Zugewiesen
</div>
)}
</div>
<div className="p-4 flex flex-col flex-grow">
<h2 className="text-base font-bold text-gray-900 mb-1 truncate" id={`album-${album.id}`} title={album.albumName}>
{album.albumName}
</h2>
<p className="text-sm text-gray-500 mb-4">{album.assetCount} Fotos</p>
<div className="mt-auto space-y-2">
<form action={handleAction}>
<input name="immichAlbumId" type="hidden" value={album.id} />
<button
type="submit"
className={`w-full py-2 px-4 rounded-lg font-semibold text-sm transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-1 ${
album.isGranted
? "bg-red-50 text-red-600 hover:bg-red-100 focus:ring-red-500 border border-red-200"
: "bg-gray-900 text-white hover:bg-gray-800 focus:ring-gray-900"
}`}
disabled={isPending}
>
{isPending ? "Wird verarbeitet..." : album.isGranted ? "Zuweisung aufheben" : "Album zuweisen"}
</button>
</form>
<li data-granted={album.isGranted}>
<Card className={`h-full ${album.isGranted ? "outline-2 outline-[var(--color-success-solid)]" : ""}`}>
<div className="relative aspect-[3/2] overflow-hidden rounded-[var(--radius-lg)] bg-[var(--color-bg-subtle)]">
{album.albumThumbnailAssetId ? (
<img
className="h-full w-full object-contain"
alt={`Titelbild von ${album.albumName}`}
loading="lazy"
src={`/api/assets/${encodeURIComponent(album.albumThumbnailAssetId)}/thumbnail?albumId=${encodeURIComponent(album.id)}`}
/>
) : (
<div aria-label="Kein Albumcover verfügbar" className="grid h-full w-full place-items-center text-xs text-[var(--color-fg-muted)]" role="img">
Kein Cover
</div>
)}
{album.isGranted && (
<form action={(formData) => {
setNotifyStatus("pending");
notifyAction(editorialId, { ok: true, message: "" }, formData).then((res) => {
setNotifyStatus(res.ok ? "success" : "error");
setTimeout(() => setNotifyStatus("idle"), 3000);
});
}}>
<Badge className="absolute top-2 right-2" emphasis="solid" variant="success">Zugewiesen</Badge>
)}
</div>
<div className="flex flex-col gap-1">
<h2 className="truncate text-base font-semibold" id={`album-${album.id}`} title={album.albumName}>
{album.albumName}
</h2>
<p className="text-sm text-[var(--color-fg-muted)]">{album.assetCount} Fotos</p>
</div>
<div className="mt-auto flex flex-col gap-2">
<form action={handleAction} className="flex flex-col">
<input name="immichAlbumId" type="hidden" value={album.id} />
<Button disabled={isPending} type="submit" variant={album.isGranted ? "outline" : "primary"}>
{isPending ? "Wird verarbeitet …" : album.isGranted ? "Zuweisung aufheben" : "Album zuweisen"}
</Button>
</form>
{album.isGranted && (
<form
className="flex flex-col"
action={(formData) => {
setNotifyStatus("pending");
notifyAction(editorialId, { ok: true, message: "" }, formData).then((res) => {
setNotifyStatus(res.ok ? "success" : "error");
setTimeout(() => setNotifyStatus("idle"), 3000);
});
}}
>
<input name="albumName" type="hidden" value={album.albumName} />
<button
type="submit"
className={`w-full py-2 px-4 rounded-lg font-semibold text-sm transition-colors duration-200 border ${
notifyStatus === "success" ? "bg-green-50 text-green-700 border-green-200" :
notifyStatus === "error" ? "bg-red-50 text-red-700 border-red-200" :
"bg-white text-gray-700 hover:bg-gray-50 border-gray-200 focus:ring-2 focus:ring-gray-200 focus:outline-none"
}`}
<Button
disabled={notifyStatus === "pending" || notifyStatus === "success"}
leftIcon={<IconMail size={16} />}
type="submit"
variant={notifyStatus === "error" ? "destructive" : "ghost"}
>
{notifyStatus === "pending" ? "Wird gesendet..." :
notifyStatus === "success" ? "E-Mail gesendet!" :
notifyStatus === "error" ? "Fehler beim Senden" :
"Redaktion benachrichtigen"}
</button>
{notifyLabel}
</Button>
</form>
)}
</div>
</div>
</Card>
</li>
);
}
@@ -130,20 +128,22 @@ export function AlbumGrid({ albums, editorialId, grantAction, revokeAction, noti
);
return (
<div>
<input
type="search"
className="album-grid-search"
placeholder="Alben suchen..."
value={search}
onChange={(e) => setSearch(e.target.value)}
aria-label="Alben durchsuchen"
/>
<div className="flex flex-col gap-6">
<div className="max-w-md">
<Input
aria-label="Alben durchsuchen"
leadingIcon={<IconSearch size={16} />}
onChange={(e) => setSearch(e.target.value)}
placeholder="Alben suchen …"
type="search"
value={search}
/>
</div>
{filteredAlbums.length === 0 ? (
<p>Keine Alben gefunden.</p>
<EmptyState type="no-results" title="Keine Alben gefunden." description="Versuchen Sie einen anderen Suchbegriff." />
) : (
<ul className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-6" aria-label="Zuweisbare Immich-Alben">
<ul className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4" aria-label="Zuweisbare Immich-Alben">
{filteredAlbums.map((album) => (
<AlbumCard
key={album.id}
+31 -29
View File
@@ -1,8 +1,10 @@
import Image from "next/image";
import Link from "next/link";
import { eq } from "drizzle-orm";
import { notFound } from "next/navigation";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { Alert, EmptyState } from "@/components/ui/sakani";
import { db } from "@/db/client";
import { editorialAccounts } from "@/db/schema";
import { albumGrantService } from "@/modules/albums/grants";
@@ -26,40 +28,40 @@ export default async function EditorialAlbumsPage({
const albumResult = await loadAssignableAlbums(editorial.id, albumGrantService);
const header = (
<PageHeader
kicker="Redaktion · Albumrechte"
title={`Alben für ${editorial.name}`}
description="Nur Alben, die der technische Immich-Zugang lesen kann, lassen sich zuweisen."
>
<div className="flex flex-wrap gap-3">
<Button asChild variant="outline">
<Link href={`/admin/redaktionen/${editorial.id}`}>Zurück zur Redaktion</Link>
</Button>
<Button asChild variant="outline">
<Link href={`/admin/redaktionen/${editorial.id}/auto-regeln`}>Auto-Zuweisungsregeln verwalten</Link>
</Button>
</div>
</PageHeader>
);
if (albumResult.unavailable) {
return (
<div className="space-y-6 max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<div>
<p className="text-sm font-semibold uppercase tracking-widest text-primary-600 dark:text-primary-500 mb-2">Redaktion · Albumrechte</p>
<h1 className="text-4xl font-bold tracking-tight">Alben für {editorial.name}</h1>
</div>
<div className="bg-destructive/15 text-destructive p-4 rounded-md border border-destructive/30" role="status">
Die Immich-Alben sind momentan nicht erreichbar. Bereits bestehende Zuweisungen bleiben unverändert.
</div>
<div className="flex gap-4">
<Link href={`/admin/redaktionen/${editorial.id}`} className="text-primary-600 hover:underline">Zurück zur Redaktion</Link>
</div>
</div>
<section className="flex flex-col gap-6">
{header}
<Alert
color="warning"
description="Die Immich-Alben sind momentan nicht erreichbar. Bereits bestehende Zuweisungen bleiben unverändert."
/>
</section>
);
}
return (
<div className="space-y-8 max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<div>
<p className="text-sm font-semibold uppercase tracking-widest text-primary-600 dark:text-primary-500 mb-2">Redaktion · Albumrechte</p>
<h1 className="text-4xl font-bold tracking-tight">Alben für {editorial.name}</h1>
<p className="text-muted-foreground mt-2">
Nur Alben, die der technische Immich-Zugang lesen kann, lassen sich zuweisen.
</p>
<div className="flex gap-4 mt-4 text-sm font-medium">
<Link href={`/admin/redaktionen/${editorial.id}`} className="text-primary-600 hover:underline">Zurück zur Redaktion</Link>
<span className="text-muted-foreground">·</span>
<Link href={`/admin/redaktionen/${editorial.id}/auto-regeln`} className="text-primary-600 hover:underline">Auto-Zuweisungsregeln verwalten</Link>
</div>
</div>
<section className="flex flex-col gap-6">
{header}
{albumResult.albums.length === 0 ? (
<p className="text-muted-foreground">Derzeit sind keine zuweisbaren Alben vorhanden.</p>
<EmptyState title="Keine zuweisbaren Alben" description="Derzeit sind keine zuweisbaren Alben vorhanden." />
) : (
<AlbumGrid
albums={albumResult.albums}
@@ -69,6 +71,6 @@ export default async function EditorialAlbumsPage({
notifyAction={sendAlbumNotificationAction}
/>
)}
</div>
</section>
);
}
@@ -1,5 +1,5 @@
import Link from "next/link";
import { Plus, Play, Trash2, ArrowLeft } from "lucide-react";
import { IconPlayerPlay, IconPlus, IconTrash } from "@sakaniui/react/icons";
import { notFound } from "next/navigation";
import { autoRuleService } from "@/modules/albums/auto-rules";
@@ -8,7 +8,7 @@ import { editorialAccounts } from "@/db/schema";
import { eq } from "drizzle-orm";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { EmptyState, Input } from "@/components/ui/sakani";
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card";
import { PageHeader } from "@/components/ui/page-header";
@@ -35,21 +35,12 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
const rules = await autoRuleService.listRules(id);
return (
<div className="space-y-8 max-w-4xl animate-in fade-in slide-in-from-bottom-4 duration-500">
<PageHeader
kicker="Redaktion · Auto-Zuweisungsregeln"
title={`Auto-Regeln für ${editorial.name}`}
/>
<div className="flex gap-4 mb-6">
<Link
href={`/admin/redaktionen/${editorial.id}/alben`}
className="inline-flex items-center text-sm font-medium text-primary-600 hover:underline"
>
<ArrowLeft className="w-4 h-4 mr-1" />
Zurück zur Album-Verwaltung
</Link>
</div>
<section className="flex max-w-4xl flex-col gap-6">
<PageHeader kicker="Redaktion · Auto-Zuweisungsregeln" title={`Auto-Regeln für ${editorial.name}`}>
<Button asChild variant="outline">
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Zurück zur Album-Verwaltung</Link>
</Button>
</PageHeader>
<div className="grid gap-6">
<Card>
@@ -60,21 +51,11 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
</CardDescription>
</CardHeader>
<CardContent>
<form action={createAutoRuleAction.bind(null, editorial.id)} className="flex gap-4 items-end">
<div className="grid gap-2 flex-grow">
<label className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
Schlüsselwort
</label>
<Input
name="keyword"
type="text"
required
placeholder="z.B. FC Bayern"
className="max-w-md"
/>
<form action={createAutoRuleAction.bind(null, editorial.id)} className="flex flex-col gap-4 sm:flex-row sm:items-end">
<div className="w-full max-w-md">
<Input label="Schlüsselwort" name="keyword" placeholder="z.B. FC Bayern" required type="text" />
</div>
<Button type="submit">
<Plus className="w-4 h-4 mr-2" />
<Button type="submit" leftIcon={<IconPlus size={16} />}>
Regel hinzufügen
</Button>
</form>
@@ -83,7 +64,7 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
<Card>
<CardHeader>
<div className="flex items-start justify-between">
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<CardTitle>Bestehende Regeln</CardTitle>
<CardDescription>
@@ -91,8 +72,7 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
</CardDescription>
</div>
<form action={applyAutoRulesAction.bind(null, editorial.id)}>
<Button type="submit" variant="secondary">
<Play className="w-4 h-4 mr-2" />
<Button type="submit" variant="secondary" leftIcon={<IconPlayerPlay size={16} />}>
Regeln jetzt anwenden
</Button>
</form>
@@ -100,20 +80,19 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
</CardHeader>
<CardContent>
{rules.length === 0 ? (
<p className="text-muted-foreground text-sm">Noch keine Auto-Regeln angelegt.</p>
<EmptyState title="Noch keine Auto-Regeln angelegt." description="Legen Sie oben ein Schlüsselwort an." />
) : (
<ul className="divide-y divide-border border rounded-md">
<ul className="divide-y divide-[var(--color-border-subtle)] rounded-[var(--radius-md)] border border-[var(--color-border-subtle)]">
{rules.map((rule) => (
<li key={rule.id} className="flex items-center justify-between p-4">
<div className="flex flex-col">
<span className="font-medium">{rule.keyword}</span>
<span className="text-xs text-muted-foreground mt-1">
<span className="mt-1 text-xs text-[var(--color-fg-muted)]">
Erstellt am {new Date(rule.createdAt).toLocaleDateString('de-DE')}
</span>
</div>
<form action={deleteAutoRuleAction.bind(null, editorial.id, rule.id)}>
<Button type="submit" variant="ghost" size="sm" className="text-destructive hover:bg-destructive/10 hover:text-destructive">
<Trash2 className="w-4 h-4 mr-2" />
<Button type="submit" variant="ghost" size="sm" leftIcon={<IconTrash size={16} />}>
Entfernen
</Button>
</form>
@@ -124,6 +103,6 @@ export default async function AutoRulesPage({ params }: AutoRulesPageProps) {
</CardContent>
</Card>
</div>
</div>
</section>
);
}
+58 -62
View File
@@ -3,7 +3,8 @@ import Link from "next/link";
import { db } from "@/db/client";
import { editorialAccounts, usages } from "@/db/schema";
import { PageHeader } from "@/components/ui/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { IconChevronRight } from "@sakaniui/react/icons";
import { Badge, Card, EmptyState } from "@/components/ui/sakani";
export default async function EditorialsPage() {
const [editorials, openUsageTotals] = await Promise.all([
@@ -40,7 +41,7 @@ export default async function EditorialsPage() {
const archivedEditorials = editorials.filter((e) => e.archivedAt);
return (
<div className="space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500 max-w-7xl">
<section className="flex flex-col gap-6">
<PageHeader
kicker="Kontoverwaltung"
title="Redaktionen"
@@ -48,89 +49,84 @@ export default async function EditorialsPage() {
/>
{activeEditorials.length === 0 ? (
<p className="text-muted-foreground">Noch keine aktiven Redaktionen registriert.</p>
<EmptyState title="Noch keine aktiven Redaktionen registriert." description="Neue Registrierungen erscheinen hier zur Freigabe." />
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{activeEditorials.map((editorial) => (
<Link key={editorial.id} href={`/admin/redaktionen/${editorial.id}`} className="block group">
<Card className="h-full transition-all duration-300 hover:shadow-md hover:border-primary-500/50 hover:-translate-y-1">
<CardContent className="p-6 flex flex-col h-full justify-between">
<div>
<h3 className="text-xl font-semibold mb-2 group-hover:text-primary-600 dark:group-hover:text-primary-400 transition-colors">
{editorial.name}
</h3>
<div className="space-y-1 text-sm text-muted-foreground">
<p className="flex items-center gap-2">
<span className="font-medium text-foreground">Kontakt:</span> {editorial.contactName}
</p>
<p className="flex items-center gap-2">
<span className="font-medium text-foreground">E-Mail:</span> {editorial.loginEmail}
</p>
<p className="flex items-center gap-2">
<span className="font-medium text-foreground">Status:</span>
<span className={`px-2 py-0.5 rounded-full text-xs font-medium ${
editorial.status === "active" ? "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400" :
editorial.status === "pending_approval" ? "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400" :
"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"
}`}>
{editorial.status === "active" ? "Aktiv" : editorial.status === "pending_approval" ? "Ausstehend" : "Gesperrt"}
</span>
</p>
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{activeEditorials.map((editorial) => {
const openCents = openCentsByEditorial.get(editorial.id) ?? 0;
return (
<li key={editorial.id}>
<Link href={`/admin/redaktionen/${editorial.id}`} className={CARD_LINK}>
<Card interactive className="h-full">
<div className="flex items-start justify-between gap-3">
<h2 className="text-base font-semibold text-[var(--color-fg-default)]">{editorial.name}</h2>
<Badge variant={STATUS[editorial.status]?.variant ?? "danger"}>
{STATUS[editorial.status]?.label ?? "Gesperrt"}
</Badge>
</div>
</div>
<div className="mt-6 pt-4 border-t border-border">
<p className="text-sm font-medium">
<dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-sm">
<dt className="text-[var(--color-fg-muted)]">Kontakt</dt>
<dd className="truncate">{editorial.contactName}</dd>
<dt className="text-[var(--color-fg-muted)]">E-Mail</dt>
<dd className="truncate">{editorial.loginEmail}</dd>
</dl>
<p className="mt-auto border-t border-[var(--color-border-subtle)] pt-3 text-sm font-medium">
{editorial.currentPriceCents === null
? "Preis noch nicht festgelegt"
: `Netto ${formatCents(editorial.currentPriceCents)}`}
<span
className={`ml-2 ${(openCentsByEditorial.get(editorial.id) ?? 0) > 0 ? "text-amber-600 dark:text-amber-400" : "text-muted-foreground"}`}
className={`ml-2 ${openCents > 0 ? "text-[var(--color-warning-fg)]" : "text-[var(--color-fg-muted)]"}`}
title="Summe der noch nicht abgerechneten Bildnutzungen"
>
· Offen {formatCents(openCentsByEditorial.get(editorial.id) ?? 0)}
· Offen {formatCents(openCents)}
</span>
</p>
</div>
</CardContent>
</Card>
</Link>
))}
</div>
</Card>
</Link>
</li>
);
})}
</ul>
)}
{archivedEditorials.length > 0 && (
<details className="mt-12 group">
<summary className="cursor-pointer flex items-center gap-2 text-sm font-semibold uppercase tracking-widest text-muted-foreground hover:text-foreground transition-colors mb-6 list-none">
<span className="bg-muted p-1 rounded-sm group-open:rotate-90 transition-transform">
▶
</span>
<details className="group mt-6">
<summary className="mb-4 flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-[var(--color-fg-muted)] hover:text-[var(--color-fg-default)]">
<IconChevronRight size={16} aria-hidden="true" className="transition-transform group-open:rotate-90" />
Archivierte Redaktionen ({archivedEditorials.length})
</summary>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 opacity-75 grayscale hover:grayscale-0 transition-all duration-500">
<ul className="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
{archivedEditorials.map((editorial) => (
<Link key={editorial.id} href={`/admin/redaktionen/${editorial.id}`} className="block group">
<Card className="h-full transition-all duration-300 hover:shadow-sm">
<CardContent className="p-6">
<h3 className="text-lg font-semibold mb-2 text-muted-foreground group-hover:text-foreground transition-colors">
{editorial.name}
</h3>
<div className="space-y-1 text-sm text-muted-foreground">
<p>{editorial.contactName} · {editorial.loginEmail}</p>
<p className="pt-2">
Archiviert am: {editorial.archivedAt ? new Date(editorial.archivedAt).toLocaleDateString("de-DE") : ""}
</p>
<li key={editorial.id}>
<Link href={`/admin/redaktionen/${editorial.id}`} className={CARD_LINK}>
<Card interactive className="h-full opacity-80">
<div className="flex items-start justify-between gap-3">
<h2 className="text-base font-semibold text-[var(--color-fg-muted)]">{editorial.name}</h2>
<Badge>Archiviert</Badge>
</div>
</CardContent>
</Card>
</Link>
<p className="text-sm text-[var(--color-fg-muted)]">{editorial.contactName} · {editorial.loginEmail}</p>
<p className="text-sm text-[var(--color-fg-muted)]">
Archiviert am: {editorial.archivedAt ? new Date(editorial.archivedAt).toLocaleDateString("de-DE") : ""}
</p>
</Card>
</Link>
</li>
))}
</div>
</ul>
</details>
)}
</div>
</section>
);
}
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<string, { label: string; variant: "success" | "warning" | "danger" }> = {
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);
}