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,11 @@
|
||||
import "server-only";
|
||||
|
||||
import { cache } from "react";
|
||||
|
||||
import { headers } from "next/headers";
|
||||
|
||||
import { requireActiveEditorial } from "@/modules/auth/principal";
|
||||
|
||||
export const requireEditorial = cache(async () =>
|
||||
requireActiveEditorial(new Headers(await headers())),
|
||||
);
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { PortalShell } from "@/components/layout/portal-shell";
|
||||
|
||||
import { requireEditorial } from "./access";
|
||||
|
||||
export default async function EditorialLayout({ children }: Readonly<{ children: ReactNode }>) {
|
||||
await requireEditorial();
|
||||
|
||||
return <PortalShell>{children}</PortalShell>;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
import { db } from "@/db/client";
|
||||
import { billingAddressVersions, editorialAccounts } from "@/db/schema";
|
||||
import { requireActiveEditorial } from "@/modules/auth/principal";
|
||||
|
||||
import { requireEditorial } from "../access";
|
||||
|
||||
export default async function EditorialProfilePage() {
|
||||
const principal = await requireActiveEditorial(new Headers(await headers()));
|
||||
const principal = await requireEditorial();
|
||||
const [editorial] = await db
|
||||
.select({
|
||||
name: editorialAccounts.name,
|
||||
@@ -27,35 +27,33 @@ export default async function EditorialProfilePage() {
|
||||
.limit(1);
|
||||
|
||||
return (
|
||||
<main className="portal-shell">
|
||||
<section className="content-section" aria-labelledby="profile-title">
|
||||
<p className="eyebrow">Redaktionskonto</p>
|
||||
<h1 id="profile-title">Profil</h1>
|
||||
<dl>
|
||||
<dt>Redaktion</dt>
|
||||
<dd>{editorial?.name}</dd>
|
||||
<dt>Ansprechperson</dt>
|
||||
<dd>{editorial?.contactName}</dd>
|
||||
<dt>Anmelde-E-Mail</dt>
|
||||
<dd>{editorial?.loginEmail}</dd>
|
||||
<dt>Rechnungsadresse</dt>
|
||||
<dd>
|
||||
{editorial?.addressLine1 ? (
|
||||
<address>
|
||||
{editorial.addressLine1}
|
||||
{editorial.addressLine2 ? <br /> : null}
|
||||
{editorial.addressLine2}
|
||||
<br />
|
||||
{editorial.postalCode} {editorial.city}
|
||||
<br />
|
||||
{editorial.countryCode}
|
||||
</address>
|
||||
) : (
|
||||
"Keine Rechnungsadresse hinterlegt."
|
||||
)}
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</main>
|
||||
<section className="editorial-section" aria-labelledby="profile-title">
|
||||
<p className="eyebrow">Redaktionskonto</p>
|
||||
<h1 id="profile-title">Profil</h1>
|
||||
<dl>
|
||||
<dt>Redaktion</dt>
|
||||
<dd>{editorial?.name}</dd>
|
||||
<dt>Ansprechperson</dt>
|
||||
<dd>{editorial?.contactName}</dd>
|
||||
<dt>Anmelde-E-Mail</dt>
|
||||
<dd>{editorial?.loginEmail}</dd>
|
||||
<dt>Rechnungsadresse</dt>
|
||||
<dd>
|
||||
{editorial?.addressLine1 ? (
|
||||
<address>
|
||||
{editorial.addressLine1}
|
||||
{editorial.addressLine2 ? <br /> : null}
|
||||
{editorial.addressLine2}
|
||||
<br />
|
||||
{editorial.postalCode} {editorial.city}
|
||||
<br />
|
||||
{editorial.countryCode}
|
||||
</address>
|
||||
) : (
|
||||
"Keine Rechnungsadresse hinterlegt."
|
||||
)}
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user