diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 45a10c8..54713a3 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -4,6 +4,7 @@ import { usages, editorialAccounts } from "@/db/schema"; import { requireAdmin } from "@/modules/auth/principal"; import { headers } from "next/headers"; 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"; @@ -51,10 +52,10 @@ export default async function AdminDashboardPage() { return (
-
-

Admin Dashboard

-

Willkommen zurück! Hier ist ein Überblick über die aktuelle Nutzung des Portals.

-
+
diff --git a/src/app/admin/redaktionen/page.tsx b/src/app/admin/redaktionen/page.tsx index cdae888..0ba2da6 100644 --- a/src/app/admin/redaktionen/page.tsx +++ b/src/app/admin/redaktionen/page.tsx @@ -1,5 +1,7 @@ import { desc } from "drizzle-orm"; +import { PageHeader } from "@/components/ui/page-header"; + import { db } from "@/db/client"; import { editorialAccounts } from "@/db/schema"; @@ -23,8 +25,11 @@ export default async function EditorialsPage() { return (
-

Kontoverwaltung

-

Redaktionen

+ {activeEditorials.length === 0 ? (

Noch keine aktiven Redaktionen registriert.

) : ( diff --git a/src/app/redaktion/alben/[albumId]/page.tsx b/src/app/redaktion/alben/[albumId]/page.tsx index b9b36a8..4bf18e4 100644 --- a/src/app/redaktion/alben/[albumId]/page.tsx +++ b/src/app/redaktion/alben/[albumId]/page.tsx @@ -7,6 +7,7 @@ import { loadEditorialDownloadOptions } from "@/modules/downloads/stream"; import { lightboxService } from "@/modules/lightbox/service"; import { requireEditorial } from "../../access"; +import { PageHeader } from "@/components/ui/page-header"; type AlbumPageProps = Readonly<{ params: Promise<{ albumId: string }>; @@ -41,13 +42,15 @@ export default async function AlbumPage({ params, searchParams }: AlbumPageProps return (
-

Bildarchiv · {result.album.assetCount} freigegebene Fotos

-
-

{result.album.albumName}

+ Alle Alben -
+ -

Bildarchiv

-

Fotos momentan nicht erreichbar

-

Bitte laden Sie diese Seite in wenigen Minuten erneut.

- - Zurück zu den Alben - + +
+

Bitte laden Sie diese Seite in wenigen Minuten erneut.

+ + Zurück zu den Alben + +
+
); } diff --git a/src/app/redaktion/alben/page.tsx b/src/app/redaktion/alben/page.tsx index 55cc635..fb74bfe 100644 --- a/src/app/redaktion/alben/page.tsx +++ b/src/app/redaktion/alben/page.tsx @@ -4,6 +4,7 @@ import { loadEditorialDownloadOptions } from "@/modules/downloads/stream"; import { lightboxService } from "@/modules/lightbox/service"; import type { ImmichSearchPage } from "@/modules/immich/types"; import Link from "next/link"; +import { PageHeader } from "@/components/ui/page-header"; import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; @@ -56,10 +57,11 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi return (
-
-

Bildarchiv · Suche

-

Suchergebnisse

-
+ -
-

Bildarchiv · Freigaben

-

Ihre Alben

-

Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen.

-
+ {result.albums.length === 0 ? (

Für Ihre Redaktion sind noch keine Fotoalben freigegeben.

@@ -169,10 +172,11 @@ async function loadAlbums(editorialId: string) { function ImmichUnavailable() { return (
-
-

Bildarchiv

-

Alben momentan nicht erreichbar

-
+
Bitte laden Sie diese Seite in wenigen Minuten erneut. Ihre Freigaben bleiben unverändert.
diff --git a/src/app/redaktion/leuchtkasten/page.tsx b/src/app/redaktion/leuchtkasten/page.tsx index 9e62a36..c0ecb11 100644 --- a/src/app/redaktion/leuchtkasten/page.tsx +++ b/src/app/redaktion/leuchtkasten/page.tsx @@ -1,4 +1,5 @@ import { headers } from "next/headers"; +import { PageHeader } from "@/components/ui/page-header"; import { requireActiveEditorial } from "@/modules/auth/principal"; import { lightboxService } from "@/modules/lightbox/service"; import { immichClient } from "@/modules/immich/client"; @@ -21,10 +22,10 @@ export default async function LightboxPage() { return (
-
-

Merkzettel

-

Dein Leuchtkasten

-
+ {items.length === 0 ? (

Dein Leuchtkasten ist leer.

diff --git a/src/app/redaktion/nutzungen/usage-history-content.tsx b/src/app/redaktion/nutzungen/usage-history-content.tsx index ff091a7..359c38d 100644 --- a/src/app/redaktion/nutzungen/usage-history-content.tsx +++ b/src/app/redaktion/nutzungen/usage-history-content.tsx @@ -1,5 +1,7 @@ import Link from "next/link"; +import { PageHeader } from "@/components/ui/page-header"; + import { formatBerlinDateTime } from "@/modules/downloads/format"; import type { UsageHistoryAttempt, UsageHistoryPage } from "@/modules/downloads/stream"; @@ -17,11 +19,12 @@ const byteFormatter = new Intl.NumberFormat("de-DE", { export function UsageHistoryContent({ history }: Readonly<{ history: UsageHistoryPage }>) { return (
-

Abrechnung · Downloadprotokoll

-
-

Ihre Nutzungen

-

Verwendungszwecke, Kosten und Auslieferungsversuche Ihrer Redaktion.

-
+ {history.items.length === 0 ? (
diff --git a/src/app/redaktion/profil/page.tsx b/src/app/redaktion/profil/page.tsx index 9eb1595..4ddebce 100644 --- a/src/app/redaktion/profil/page.tsx +++ b/src/app/redaktion/profil/page.tsx @@ -1,5 +1,7 @@ import { eq } from "drizzle-orm"; +import { PageHeader } from "@/components/ui/page-header"; + import { db } from "@/db/client"; import { billingAddressVersions, editorialAccounts } from "@/db/schema"; @@ -28,8 +30,11 @@ export default async function EditorialProfilePage() { return (
-

Redaktionskonto

-

Profil

+
Redaktion
{editorial?.name}
diff --git a/src/components/brand/logo.tsx b/src/components/brand/logo.tsx index 5c23c5b..7ca5dbd 100644 --- a/src/components/brand/logo.tsx +++ b/src/components/brand/logo.tsx @@ -1,22 +1,13 @@ /* eslint-disable @next/next/no-img-element */ -type BrandLogoProps = { - variant: "black" | "white"; -}; - -export function BrandLogo({ variant }: Readonly) { - const logo = - variant === "white" - ? { source: "/brand/logo-white.png", width: 250, height: 250 } - : { source: "/brand/logo-black.png", width: 1000, height: 1000 }; - +export function BrandLogo() { return ( Leon Tonhäuser Sportfotografie ); } diff --git a/src/components/layout/portal-shell.tsx b/src/components/layout/portal-shell.tsx index e773382..141cf94 100644 --- a/src/components/layout/portal-shell.tsx +++ b/src/components/layout/portal-shell.tsx @@ -32,9 +32,7 @@ export function PortalShell({
- {/* The BrandLogo might need to be theme-aware or we just use white/black depending on theme */} -
-
+
{sectionLabel} diff --git a/src/components/ui/page-header.tsx b/src/components/ui/page-header.tsx new file mode 100644 index 0000000..26b69e2 --- /dev/null +++ b/src/components/ui/page-header.tsx @@ -0,0 +1,31 @@ +import * as React from "react" +import { cn } from "@/lib/utils" + +export interface PageHeaderProps extends React.HTMLAttributes { + kicker?: React.ReactNode; + title: React.ReactNode; + description?: React.ReactNode; + titleId?: string; +} + +export function PageHeader({ + className, + kicker, + title, + description, + titleId, + children, + ...props +}: PageHeaderProps) { + return ( +
+ {kicker &&

{kicker}

} +
+

{title}

+ {description &&

{description}

} + {children} +
+
+ ) +} + diff --git a/src/modules/pdf/document.ts b/src/modules/pdf/document.ts index 5cdfa10..9f06e90 100644 --- a/src/modules/pdf/document.ts +++ b/src/modules/pdf/document.ts @@ -235,7 +235,7 @@ export function buildDocumentDefinition(snapshot: BillingReportSnapshot) { columns: [ { image: "logo", - width: 120, + width: 80, }, { width: "*", @@ -297,7 +297,7 @@ export function buildDocumentDefinition(snapshot: BillingReportSnapshot) { // Recipient block { stack: addressLines.map((line) => ({ text: line, style: "recipient" })), - margin: [0, 0, 0, 20], + margin: [0, 40, 0, 20], }, // Title diff --git a/src/modules/usages/service.test.ts b/src/modules/usages/service.test.ts index 49b7fd7..83d1287 100644 --- a/src/modules/usages/service.test.ts +++ b/src/modules/usages/service.test.ts @@ -92,15 +92,10 @@ function createRepository() { function createService() { const state = createRepository(); const immich = { - listAlbumsForAsset: vi.fn().mockResolvedValue([ - { - id: albumId, - albumName: "Presse 2026", - description: null, - albumThumbnailAssetId: assetId, - assetCount: 1, - }, - ]), + getAlbum: vi.fn().mockResolvedValue({ + id: albumId, + albumName: "Presse 2026", + }), getAsset: vi.fn().mockResolvedValue({ id: assetId, type: "IMAGE" as const, @@ -162,7 +157,7 @@ test("canonicalizes every UUID before fingerprinting, lookup, Immich calls, and expect(second).toEqual(first); expect(usages).toHaveLength(1); expect(usages[0]).toMatchObject({ editorialId, assetId, albumId, idempotencyKey }); - expect(immich.listAlbumsForAsset).toHaveBeenCalledWith(assetId); + expect(immich.getAlbum).toHaveBeenCalledWith(albumId); expect(immich.getAsset).toHaveBeenCalledWith(assetId); }); @@ -231,72 +226,54 @@ test.each([ }), ).rejects.toMatchObject({ code }); expect(findIntent).not.toHaveBeenCalled(); - expect(immich.listAlbumsForAsset).not.toHaveBeenCalled(); + expect(immich.getAlbum).not.toHaveBeenCalled(); expect(immich.getAsset).not.toHaveBeenCalled(); }, ); test("rejects an asset outside the exact requested album", async () => { const { service, immich, usages } = createService(); - immich.listAlbumsForAsset.mockResolvedValue([ - { - id: otherAlbumId, - albumName: "Andere Bilder", - description: null, - albumThumbnailAssetId: null, - assetCount: 1, - }, - ]); + immich.getAsset.mockResolvedValue({ + id: assetId, + type: "IMAGE", + originalFileName: "jubel.jpg", + albums: [{ id: otherAlbumId }], + }); await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ code: "ASSET_NOT_IN_ALBUM", }); - expect(immich.getAsset).not.toHaveBeenCalled(); + expect(immich.getAlbum).not.toHaveBeenCalled(); expect(usages).toHaveLength(0); }); test("rejects removal from the requested album between preflight and locked refresh", async () => { const { service, immich, usages } = createService(); - immich.listAlbumsForAsset - .mockResolvedValueOnce([ - { - id: albumId, - albumName: "Presse 2026", - description: null, - albumThumbnailAssetId: assetId, - assetCount: 1, - }, - ]) - .mockResolvedValueOnce([]); + const currentAsset = { + id: assetId, + type: "IMAGE" as const, + originalFileName: "jubel.jpg", + originalMimeType: "image/jpeg", + localDateTime: null, + fileCreatedAt: null, + albums: [{ id: albumId }], + }; + immich.getAsset + .mockResolvedValueOnce(currentAsset) + .mockResolvedValueOnce({ ...currentAsset, albums: [] }); await expect(service.createNewUsage(newUsageInput)).rejects.toMatchObject({ code: "ASSET_NOT_IN_ALBUM", }); - expect(immich.listAlbumsForAsset).toHaveBeenCalledTimes(2); + expect(immich.getAsset).toHaveBeenCalledTimes(2); expect(usages).toHaveLength(0); }); test("persists metadata from the locked final Immich refresh", async () => { const { service, immich, usages } = createService(); - immich.listAlbumsForAsset - .mockResolvedValueOnce([ - { - id: albumId, - albumName: "Presse 2026", - description: null, - albumThumbnailAssetId: assetId, - assetCount: 1, - }, - ]) - .mockResolvedValueOnce([ - { - id: albumId, - albumName: "Presse final", - description: null, - albumThumbnailAssetId: assetId, - assetCount: 1, - }, - ]); + immich.getAlbum + .mockResolvedValueOnce({ id: albumId, albumName: "Presse 2026" }) + .mockResolvedValueOnce({ id: albumId, albumName: "Presse final" }); const currentAsset = { id: assetId, type: "IMAGE" as const, @@ -317,6 +294,7 @@ test("persists metadata from the locked final Immich refresh", async () => { await service.createNewUsage(newUsageInput); expect(immich.getAsset).toHaveBeenCalledTimes(2); + expect(immich.getAlbum).toHaveBeenCalledTimes(2); expect(usages).toEqual([ expect.objectContaining({ albumName: "Presse final", filename: "final.jpg" }), ]); diff --git a/src/modules/usages/service.ts b/src/modules/usages/service.ts index d43946e..6b86d2e 100644 --- a/src/modules/usages/service.ts +++ b/src/modules/usages/service.ts @@ -57,11 +57,12 @@ export type UsageRepository = { }; type UsageImmich = { - listAlbumsForAsset(assetId: string): Promise; + getAlbum(albumId: string): Promise<{ id: string; albumName: string }>; getAsset(assetId: string): Promise<{ id: string; type: string; originalFileName: string; + albums?: { id: string }[]; }>; }; @@ -87,16 +88,16 @@ export function createUsageService({ const existing = await repository.findIntent(input.editorialId, input.idempotencyKey); if (existing) return resolveIntent(existing, fingerprint, "new_usage"); - const album = await loadRequestedAlbum(immich, input.assetId, input.albumId); const asset = await loadImageAsset(immich, input.assetId); + const album = await loadRequestedAlbum(immich, asset, input.albumId); const persisted = await repository.createBillableIntent({ ...input, albumName: normalizeUpstreamSnapshot(album.albumName), filename: normalizeUpstreamSnapshot(asset.originalFileName), requestFingerprint: fingerprint, }, async () => { - const currentAlbum = await loadRequestedAlbum(immich, input.assetId, input.albumId); const currentAsset = await loadImageAsset(immich, input.assetId); + const currentAlbum = await loadRequestedAlbum(immich, currentAsset, input.albumId); return { albumName: normalizeUpstreamSnapshot(currentAlbum.albumName), filename: normalizeUpstreamSnapshot(currentAsset.originalFileName), @@ -328,17 +329,18 @@ function normalizeNewUsageInput(input: CreateNewUsageInput): CreateNewUsageInput async function loadRequestedAlbum( immich: UsageImmich, - assetId: string, + asset: Awaited>, albumId: string, -): Promise { - let albums: ImmichAlbumSummary[]; +): Promise<{ id: string; albumName: string }> { + if (!asset.albums?.some((a) => a.id === albumId)) { + throw new UsageAccountingError("ASSET_NOT_IN_ALBUM"); + } + let album; try { - albums = await immich.listAlbumsForAsset(assetId); + album = await immich.getAlbum(albumId); } catch { throw new UsageAccountingError("IMMICH_UNAVAILABLE"); } - const album = albums.find((candidate) => candidate.id === albumId); - if (!album) throw new UsageAccountingError("ASSET_NOT_IN_ALBUM"); return album; }