feat: complete UI design system refactoring and fix TS build errors

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 03:38:34 +02:00
1 parent 0b1ffdfdfc
commit 8728308fc6
27 files changed
+847 -370

No files matched your search

+1
View File
@@ -49,6 +49,7 @@ export function PhotoContactSheet({
page,
query,
showAlbumName = false,
lightboxAssetIds,
}: Readonly<{
albumId?: string;
albumName: string;
+6
View File
@@ -24,6 +24,7 @@ const validSelection = {
usageIds: ["u1", "u2"],
period,
adminUserId: "a1",
flatrateCentsSnapshot: null,
};
const address: BillingReportAddress = {
@@ -69,6 +70,10 @@ function createMockRepo() {
return address;
},
async getEditorialFlatrate() {
return { flatrateActive: false, flatratePriceCents: null, flatrateAssetLimit: null };
},
async getSelectedUsages(_editorialId, usageIds) {
return usageIds.map((id) => selectedUsage(id, usageStatuses.get(id) as "open" | "reopened"));
},
@@ -233,6 +238,7 @@ test("previewReport returns PDF bytes without persisting or billing", async () =
editorialId: validSelection.editorialId,
usageIds: validSelection.usageIds,
period: validSelection.period,
flatrateCentsSnapshot: null,
});
expect(bytes).toBeInstanceOf(Buffer);
+1
View File
@@ -55,6 +55,7 @@ export type ReportSelection = {
editorialId: string;
usageIds: string[];
period: BillingPeriod;
flatrateCentsSnapshot: number | null;
};
export type FinalizeReportInput = ReportSelection & {
+34 -23
View File
@@ -3,6 +3,9 @@
import { useState, useTransition } from "react";
import { archiveEditorialAction } from "@/app/admin/redaktionen/[id]/actions";
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
type DangerZoneProps = {
editorialId: string;
@@ -22,28 +25,36 @@ export function DangerZone({ editorialId, editorialName }: DangerZoneProps) {
}
return (
<section className="danger-zone" aria-labelledby="danger-title">
<h2 id="danger-title">Gefahrenzone</h2>
<p>Alle Albumrechte werden widerrufen und der Login wird deaktiviert. Abrechnungsdaten bleiben erhalten.</p>
<label>
<span>Redaktionsname zur Bestätigung eingeben:</span>
<input
type="text"
value={confirmText}
onChange={(e) => setConfirmText(e.target.value)}
placeholder={editorialName}
className="danger-zone-input"
disabled={isPending}
/>
</label>
<button
type="button"
className="action-button action-button--danger"
disabled={!isConfirmed || isPending}
onClick={handleArchive}
>
{isPending ? "Wird archiviert…" : "Redaktion archivieren"}
</button>
</section>
<Card className="border-destructive/50 bg-destructive/5 dark:bg-destructive/10">
<CardHeader>
<CardTitle className="text-destructive">Gefahrenzone</CardTitle>
<CardDescription>
Alle Albumrechte werden widerrufen und der Login wird deaktiviert. Abrechnungsdaten bleiben erhalten.
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<label className="text-sm font-medium">
Redaktionsname zur Bestätigung eingeben:
</label>
<Input
type="text"
value={confirmText}
onChange={(e) => setConfirmText(e.target.value)}
placeholder={editorialName}
disabled={isPending}
className="border-destructive/30 focus-visible:ring-destructive"
/>
</div>
<Button
type="button"
variant="destructive"
disabled={!isConfirmed || isPending}
onClick={handleArchive}
>
{isPending ? "Wird archiviert…" : "Redaktion archivieren"}
</Button>
</CardContent>
</Card>
);
}
+141 -99
View File
@@ -1,4 +1,7 @@
import Link from "next/link";
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { archiveEditorialAction, suspendEditorialAction, reactivateEditorialAction, updateFlatrateAction } from "@/app/admin/redaktionen/[id]/actions";
import { DangerZone } from "./DangerZone";
@@ -21,121 +24,160 @@ export function EditorialDetailContent({
hasActiveGrant,
}: Readonly<{ editorial: EditorialDetail; hasActiveGrant: boolean }>) {
return (
<section className="content-section" aria-labelledby="editorial-title">
<p className="eyebrow">Redaktion</p>
<h1 id="editorial-title">{editorial.name}</h1>
<div className="space-y-8 max-w-4xl 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</p>
<h1 className="text-4xl font-bold tracking-tight">{editorial.name}</h1>
</div>
{editorial.archivedAt && (
<p className="danger-banner" role="status">
<div className="bg-destructive/15 text-destructive p-4 rounded-md border border-destructive/30" role="status">
Diese Redaktion wurde am {editorial.archivedAt.toLocaleDateString('de-DE')} archiviert.
</p>
</div>
)}
<dl>
<dt>Ansprechperson</dt>
<dd>{editorial.contactName}</dd>
<dt>Anmelde-E-Mail</dt>
<dd>{editorial.loginEmail}</dd>
<dt>Status</dt>
<dd>{editorial.status}</dd>
<dt>E-Mail bestätigt</dt>
<dd>{editorial.emailVerifiedAt ? "Ja" : "Nein"}</dd>
<dt>Individueller Nettopreis</dt>
<dd>
{editorial.currentPriceCents === null
? "Noch nicht festgelegt"
: formatCents(editorial.currentPriceCents)}
</dd>
</dl>
<section aria-labelledby="approval-title">
<h2 id="approval-title">Freigabe</h2>
<button type="button" disabled aria-describedby="approval-help">
Redaktion freigeben
</button>
<p id="approval-help">
{hasActiveGrant
? "Mindestens ein Albumrecht ist zugewiesen. Die Freigabe bleibt bis zur weiteren Verwaltungsoberfläche deaktiviert."
: "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde."}
</p>
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Albumrechte verwalten</Link>
{" · "}
<Link href={`/admin/redaktionen/${editorial.id}/auto-regeln`}>Auto-Zuweisungsregeln</Link>
</section>
{/* Flatrate Settings */}
{!editorial.archivedAt && (
<section aria-labelledby="flatrate-title" className="mt-8">
<h2 id="flatrate-title">Flatrate-Einstellungen</h2>
<form action={updateFlatrateAction.bind(null, editorial.id)} className="space-y-4 max-w-lg mt-4">
<Card>
<CardHeader>
<CardTitle>Stammdaten</CardTitle>
</CardHeader>
<CardContent>
<dl className="grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-4">
<div>
<label className="flex items-center gap-2 font-semibold">
<input type="checkbox" name="flatrateActive" defaultChecked={editorial.flatrateActive} />
Flatrate aktivieren
</label>
<p className="text-sm text-gray-500 mt-1">Wenn aktiviert, werden Downloads nach einem Pauschalpreis abgerechnet.</p>
<dt className="text-sm font-medium text-muted-foreground">Ansprechperson</dt>
<dd className="mt-1 font-medium">{editorial.contactName}</dd>
</div>
<div className="flex gap-4">
<div className="flex-1">
<label className="block font-semibold mb-1" htmlFor="flatratePriceEuros">Flatrate-Preis (Netto €)</label>
<input
type="number"
id="flatratePriceEuros"
name="flatratePriceEuros"
step="0.01"
min="0"
className="border p-2 rounded w-full"
defaultValue={editorial.flatratePriceCents ? (editorial.flatratePriceCents / 100).toFixed(2) : ""}
/>
</div>
<div className="flex-1">
<label className="block font-semibold mb-1" htmlFor="flatrateAssetLimit">Bild-Limit (pro Monat)</label>
<input
type="number"
id="flatrateAssetLimit"
name="flatrateAssetLimit"
min="1"
placeholder="Unbegrenzt"
className="border p-2 rounded w-full"
defaultValue={editorial.flatrateAssetLimit ?? ""}
/>
<p className="text-xs text-gray-500 mt-1">Leer lassen für unbegrenzte Flatrate.</p>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">Anmelde-E-Mail</dt>
<dd className="mt-1 font-medium">{editorial.loginEmail}</dd>
</div>
<button type="submit" className="px-4 py-2 bg-black text-white font-semibold rounded hover:bg-gray-800 transition">
Speichern
</button>
</form>
</section>
)}
<div>
<dt className="text-sm font-medium text-muted-foreground">Status</dt>
<dd className="mt-1 font-medium capitalize">{editorial.status}</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">E-Mail bestätigt</dt>
<dd className="mt-1 font-medium">{editorial.emailVerifiedAt ? "Ja" : "Nein"}</dd>
</div>
<div>
<dt className="text-sm font-medium text-muted-foreground">Individueller Nettopreis</dt>
<dd className="mt-1 font-medium">
{editorial.currentPriceCents === null
? "Noch nicht festgelegt"
: formatCents(editorial.currentPriceCents)}
</dd>
</div>
</dl>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Freigabe & Rechte</CardTitle>
<CardDescription>
{hasActiveGrant
? "Mindestens ein Albumrecht ist zugewiesen. Die Freigabe bleibt bis zur weiteren Verwaltungsoberfläche deaktiviert."
: "Eine Freigabe ist erst möglich, wenn mindestens ein aktives Albumrecht zugewiesen wurde."}
</CardDescription>
</CardHeader>
<CardContent className="flex flex-col sm:flex-row gap-4 items-start sm:items-center">
<Button disabled variant="outline">
Redaktion freigeben
</Button>
<div className="flex gap-4 text-sm font-medium">
<Link href={`/admin/redaktionen/${editorial.id}/alben`} className="text-primary-600 hover:underline">
Albumrechte verwalten
</Link>
<span className="text-muted-foreground">·</span>
<Link href={`/admin/redaktionen/${editorial.id}/auto-regeln`} className="text-primary-600 hover:underline">
Auto-Zuweisungsregeln
</Link>
</div>
</CardContent>
</Card>
{/* Status Actions */}
{!editorial.archivedAt && (
<section aria-labelledby="status-actions-title">
<h2 id="status-actions-title">Status-Aktionen</h2>
{editorial.status === 'active' && (
<form action={suspendEditorialAction.bind(null, editorial.id)}>
<button type="submit" className="action-button action-button--warning">
Zugang sperren
</button>
<Card>
<CardHeader>
<CardTitle>Flatrate-Einstellungen</CardTitle>
<CardDescription>Pauschalpreis für Downloads aktivieren.</CardDescription>
</CardHeader>
<CardContent>
<form action={updateFlatrateAction.bind(null, editorial.id)} className="space-y-6">
<div className="flex items-center space-x-2">
<input
type="checkbox"
name="flatrateActive"
id="flatrateActive"
defaultChecked={editorial.flatrateActive}
className="w-4 h-4 rounded border-border text-primary-600 focus:ring-primary-500"
/>
<label htmlFor="flatrateActive" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
Flatrate aktivieren
</label>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="flatratePriceEuros">Flatrate-Preis (Netto €)</label>
<Input
type="number"
id="flatratePriceEuros"
name="flatratePriceEuros"
step="0.01"
min="0"
defaultValue={editorial.flatratePriceCents ? (editorial.flatratePriceCents / 100).toFixed(2) : ""}
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="flatrateAssetLimit">Bild-Limit (pro Monat)</label>
<Input
type="number"
id="flatrateAssetLimit"
name="flatrateAssetLimit"
min="1"
placeholder="Unbegrenzt"
defaultValue={editorial.flatrateAssetLimit ?? ""}
/>
<p className="text-xs text-muted-foreground">Leer lassen für unbegrenzte Flatrate.</p>
</div>
</div>
<Button type="submit">
Speichern
</Button>
</form>
)}
{editorial.status === 'suspended' && (
<form action={reactivateEditorialAction.bind(null, editorial.id)}>
<button type="submit" className="action-button">
Zugang reaktivieren
</button>
</form>
)}
</section>
</CardContent>
</Card>
)}
{!editorial.archivedAt && (
<Card className="border-border">
<CardHeader>
<CardTitle>Status-Aktionen</CardTitle>
</CardHeader>
<CardContent>
{editorial.status === 'active' && (
<form action={suspendEditorialAction.bind(null, editorial.id)}>
<Button type="submit" variant="destructive">
Zugang sperren
</Button>
</form>
)}
{editorial.status === 'suspended' && (
<form action={reactivateEditorialAction.bind(null, editorial.id)}>
<Button type="submit" variant="secondary">
Zugang reaktivieren
</Button>
</form>
)}
</CardContent>
</Card>
)}
{/* Danger Zone */}
{!editorial.archivedAt && (
<DangerZone editorialId={editorial.id} editorialName={editorial.name} />
)}
</section>
</div>
);
}
+4
View File
@@ -13,6 +13,10 @@ export type ImmichAsset = {
originalMimeType: string;
localDateTime: string | null;
fileCreatedAt: string | null;
exifInfo?: {
exifImageWidth?: number | null;
exifImageHeight?: number | null;
} | null;
albums: Array<{ id: string }>;
};
+2 -2
View File
@@ -2,12 +2,12 @@ import { and, eq } from "drizzle-orm";
import { db } from "@/db/client";
import { lightboxItems } from "@/db/schema";
import { immichClient } from "@/modules/immich/client";
import type { PhotoAsset } from "@/modules/immich/types";
import type { ImmichAsset } from "@/modules/immich/types";
export type LightboxItem = {
assetId: string;
addedAt: Date;
asset?: PhotoAsset; // populated if joined
asset?: ImmichAsset; // populated if joined
};
export const lightboxService = {