Files
immich-redaktions-plugin/src/app/admin/redaktionen/page.tsx
T
Leon TonhäuserandClaude Opus 5.5 cba70310f9 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 <noreply@anthropic.com>
2026-12-01 00:09:37 +01:00

71 lines
2.5 KiB
TypeScript

import { desc, inArray, sql } from "drizzle-orm";
import Link from "next/link";
import { db } from "@/db/client";
import { editorialAccounts, usages } from "@/db/schema";
import { PageHeader } from "@/components/ui/page-header";
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({
id: editorialAccounts.id,
name: editorialAccounts.name,
contactName: editorialAccounts.contactName,
loginEmail: editorialAccounts.loginEmail,
status: editorialAccounts.status,
currentPriceCents: editorialAccounts.currentPriceCents,
createdAt: editorialAccounts.createdAt,
archivedAt: editorialAccounts.archivedAt,
})
.from(editorialAccounts)
.orderBy(desc(editorialAccounts.createdAt)),
// Nicht abgerechnete Nutzungen je Redaktion — dieselben Status, die auch
// in der Abrechnung wählbar sind (voided zählt nicht).
db
.select({
editorialId: usages.editorialAccountId,
openCents: sql<number>`COALESCE(SUM(${usages.priceCents}), 0)::int`,
})
.from(usages)
.where(inArray(usages.billingStatus, ["open", "reopened"]))
.groupBy(usages.editorialAccountId),
]);
const openCentsByEditorial = new Map(
openUsageTotals.map((total) => [total.editorialId, total.openCents]),
);
return (
<section className="flex flex-col gap-6">
<PageHeader
kicker="Kontoverwaltung"
title="Redaktionen"
description="Alle registrierten Redaktionszugänge mit Status, Preis und noch nicht abgerechneten Nutzungen."
/>
{editorials.length === 0 ? (
<EmptyState title="Noch keine Redaktionen registriert." description="Neue Registrierungen erscheinen hier zur Freigabe." />
) : (
<EditorialsTable
rows={editorials.map((editorial) => ({
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(),
}))}
/>
)}
</section>
);
}