feat: add branded editorial photo catalog
This commit is contained in:
1 parent
f6e6018cc1
commit
66f0599653
20 files changed
+1299
-36
No files matched your search
@@ -0,0 +1,8 @@
|
||||
export default function AlbumLoading() {
|
||||
return (
|
||||
<section className="editorial-section editorial-state" aria-busy="true" aria-live="polite">
|
||||
<p className="editorial-kicker">Bildarchiv</p>
|
||||
<p>Fotos werden geladen.</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
|
||||
import { PhotoContactSheet } from "@/modules/albums/catalog-content";
|
||||
|
||||
import { requireEditorial } from "../../access";
|
||||
|
||||
type AlbumPageProps = Readonly<{
|
||||
params: Promise<{ albumId: string }>;
|
||||
searchParams: Promise<{ page?: string | string[]; suche?: string | string[] }>;
|
||||
}>;
|
||||
|
||||
export default async function AlbumPage({ params, searchParams }: AlbumPageProps) {
|
||||
const [{ albumId }, rawSearchParams, principal] = await Promise.all([
|
||||
params,
|
||||
searchParams,
|
||||
requireEditorial(),
|
||||
]);
|
||||
const query = normalizedQuery(singleValue(rawSearchParams.suche));
|
||||
const result = await loadAlbumPage({
|
||||
editorialId: principal.editorialId,
|
||||
albumId,
|
||||
query,
|
||||
page: singleValue(rawSearchParams.page),
|
||||
});
|
||||
|
||||
if (result.unavailable) {
|
||||
return <ImmichUnavailable />;
|
||||
}
|
||||
if (!result.album) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="editorial-section" aria-labelledby="album-title">
|
||||
<p className="editorial-kicker">Bildarchiv · {result.album.assetCount} freigegebene Fotos</p>
|
||||
<div className="editorial-title-row album-title-row">
|
||||
<h1 id="album-title">{result.album.albumName}</h1>
|
||||
<Link className="quiet-link" href="/redaktion/alben">
|
||||
Alle Alben
|
||||
</Link>
|
||||
</div>
|
||||
<PhotoContactSheet
|
||||
albumId={result.album.id}
|
||||
albumName={result.album.albumName}
|
||||
page={result.page}
|
||||
query={query}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
async function loadAlbumPage({
|
||||
editorialId,
|
||||
albumId,
|
||||
query,
|
||||
page,
|
||||
}: {
|
||||
editorialId: string;
|
||||
albumId: string;
|
||||
query: string;
|
||||
page: string | undefined;
|
||||
}) {
|
||||
try {
|
||||
const albums = await albumCatalog.getVisibleAlbums(editorialId);
|
||||
const album = albums.find((candidate) => candidate.id === albumId);
|
||||
if (!album) {
|
||||
return { album: null, page: null, unavailable: false as const };
|
||||
}
|
||||
const results = await albumCatalog.searchVisiblePhotos(editorialId, {
|
||||
requestedAlbumId: album.id,
|
||||
description: query,
|
||||
page,
|
||||
});
|
||||
return { album, page: results, unavailable: false as const };
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") {
|
||||
return { album: null, page: null, unavailable: true as const };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function singleValue(value: string | string[] | undefined): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
function normalizedQuery(value: string | undefined): string {
|
||||
return (value ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
|
||||
}
|
||||
|
||||
function ImmichUnavailable() {
|
||||
return (
|
||||
<section className="editorial-section editorial-state" aria-labelledby="album-title">
|
||||
<p className="editorial-kicker">Bildarchiv</p>
|
||||
<h1 id="album-title">Fotos momentan nicht erreichbar</h1>
|
||||
<p role="status">Bitte laden Sie diese Seite in wenigen Minuten erneut.</p>
|
||||
<Link className="quiet-link" href="/redaktion/alben">
|
||||
Zurück zu den Alben
|
||||
</Link>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export default function AlbumsLoading() {
|
||||
return (
|
||||
<section className="editorial-section editorial-state" aria-busy="true" aria-live="polite">
|
||||
<p className="editorial-kicker">Bildarchiv</p>
|
||||
<p>Alben werden geladen.</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet } from "@/modules/albums/catalog-content";
|
||||
|
||||
import { requireEditorial } from "../access";
|
||||
|
||||
export default async function AlbumsPage() {
|
||||
const principal = await requireEditorial();
|
||||
const result = await loadAlbums(principal.editorialId);
|
||||
|
||||
if (result.unavailable) {
|
||||
return <ImmichUnavailable />;
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="editorial-section" aria-labelledby="albums-title">
|
||||
<p className="editorial-kicker">Bildarchiv · Freigaben</p>
|
||||
<div className="editorial-title-row">
|
||||
<h1 id="albums-title">Ihre Alben</h1>
|
||||
<p>Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen.</p>
|
||||
</div>
|
||||
{result.albums.length === 0 ? (
|
||||
<p className="catalog-empty">Für Ihre Redaktion sind noch keine Fotoalben freigegeben.</p>
|
||||
) : (
|
||||
<AlbumContactSheet albums={result.albums} />
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
async function loadAlbums(editorialId: string) {
|
||||
try {
|
||||
return { albums: await albumCatalog.getVisibleAlbums(editorialId), unavailable: false as const };
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") {
|
||||
return { albums: [], unavailable: true as const };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function ImmichUnavailable() {
|
||||
return (
|
||||
<section className="editorial-section editorial-state" aria-labelledby="albums-title">
|
||||
<p className="editorial-kicker">Bildarchiv</p>
|
||||
<h1 id="albums-title">Alben momentan nicht erreichbar</h1>
|
||||
<p role="status">Bitte laden Sie diese Seite in wenigen Minuten erneut. Ihre Freigaben bleiben unverändert.</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user