76 lines
3.4 KiB
TypeScript
76 lines
3.4 KiB
TypeScript
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";
|
|
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { RemoveLightboxItemButton } from "./RemoveLightboxItemButton";
|
|
import { DownloadLightboxForm } from "./DownloadLightboxForm";
|
|
|
|
export default async function LightboxPage() {
|
|
const principal = await requireActiveEditorial(new Headers(await headers()));
|
|
const items = await lightboxService.getLightboxItems(principal.editorialId);
|
|
|
|
// Fetch asset details for all items in the lightbox
|
|
const assets = items.length > 0
|
|
? await Promise.all(items.map(i => immichClient.getAsset(i.assetId).catch(() => null)))
|
|
: [];
|
|
|
|
const validAssets = assets.filter((a): a is NonNullable<typeof a> => a !== null);
|
|
const assetMap = new Map(validAssets.map(a => [a.id, a]));
|
|
|
|
return (
|
|
<div className="space-y-8 max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500">
|
|
<PageHeader
|
|
kicker="Merkzettel"
|
|
title="Dein Leuchtkasten"
|
|
/>
|
|
|
|
{items.length === 0 ? (
|
|
<p className="text-muted-foreground text-center py-12">Dein Leuchtkasten ist leer.</p>
|
|
) : (
|
|
<>
|
|
<div className="flex justify-between items-center bg-card p-4 rounded-xl border border-border shadow-sm">
|
|
<p className="text-sm font-medium text-muted-foreground">
|
|
{items.length} {items.length === 1 ? 'Bild' : 'Bilder'} gemerkt
|
|
</p>
|
|
<DownloadLightboxForm assetIds={items.map(i => i.assetId)} />
|
|
</div>
|
|
|
|
<ul className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
|
|
{items.map((item) => {
|
|
const asset = assetMap.get(item.assetId);
|
|
if (!asset) return null;
|
|
|
|
return (
|
|
<li key={item.assetId} className="relative group rounded-xl overflow-hidden border border-border bg-card shadow-sm transition-all hover:shadow-md hover:-translate-y-1">
|
|
<Link href={`/redaktion/nutzungen/neu?assetId=${item.assetId}`} className="block">
|
|
<div className="aspect-[3/2] w-full overflow-hidden bg-muted">
|
|
<Image
|
|
alt={asset.originalFileName ?? "Bild"}
|
|
className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
|
|
height={200}
|
|
src={`/api/assets/${encodeURIComponent(item.assetId)}/thumbnail`}
|
|
width={300}
|
|
/>
|
|
</div>
|
|
<div className="p-3 border-t border-border bg-card">
|
|
<span className="block truncate text-xs font-medium text-muted-foreground" title={asset.originalFileName}>
|
|
{asset.originalFileName ?? "Unbekannt"}
|
|
</span>
|
|
</div>
|
|
</Link>
|
|
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
<RemoveLightboxItemButton assetId={item.assetId} />
|
|
</div>
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|