72 lines
2.7 KiB
TypeScript
72 lines
2.7 KiB
TypeScript
import { headers } from "next/headers";
|
|
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 immichClient.searchAssets({
|
|
assetIds: items.map(i => i.assetId)
|
|
})
|
|
: [];
|
|
|
|
const assetMap = new Map(assets.map(a => [a.id, a]));
|
|
|
|
return (
|
|
<section className="editorial-section">
|
|
<p className="editorial-kicker">Merkzettel</p>
|
|
<h1>Dein Leuchtkasten</h1>
|
|
|
|
{items.length === 0 ? (
|
|
<p className="mt-8 text-gray-500">Dein Leuchtkasten ist leer.</p>
|
|
) : (
|
|
<>
|
|
<div className="flex justify-between items-center mb-8">
|
|
<p className="text-sm text-gray-600">
|
|
{items.length} {items.length === 1 ? 'Bild' : 'Bilder'} gemerkt
|
|
</p>
|
|
<DownloadLightboxForm assetIds={items.map(i => i.assetId)} />
|
|
</div>
|
|
|
|
<ul className="photo-contact-sheet">
|
|
{items.map((item) => {
|
|
const asset = assetMap.get(item.assetId);
|
|
if (!asset) return null;
|
|
|
|
return (
|
|
<li key={item.assetId} className="photo-contact-frame relative group">
|
|
<Link href={`/redaktion/nutzungen/neu?assetId=${item.assetId}`} className="contact-sheet-link">
|
|
<Image
|
|
alt={asset.originalFileName}
|
|
className="contact-sheet-image"
|
|
height={200}
|
|
src={`/api/assets/${encodeURIComponent(item.assetId)}/thumbnail`}
|
|
width={300}
|
|
/>
|
|
<div className="contact-strip">
|
|
<span className="contact-strip-name" title={asset.originalFileName}>
|
|
{asset.originalFileName}
|
|
</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>
|
|
</>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|