feat: Add flatrate billing model for editorial accounts
This commit is contained in:
1 parent
699580a6a0
commit
0b1ffdfdfc
39 files changed
+4900
-57
No files matched your search
@@ -1,38 +1,71 @@
|
||||
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet, PhotoContactSheet } from "@/modules/albums/catalog-content";
|
||||
import { loadEditorialDownloadOptions } from "@/modules/downloads/stream";
|
||||
import { lightboxService } from "@/modules/lightbox/service";
|
||||
import type { ImmichSearchPage } from "@/modules/immich/types";
|
||||
import Link from "next/link";
|
||||
|
||||
import { requireEditorial } from "../access";
|
||||
|
||||
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[] }> }) {
|
||||
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[]; format?: string | string[]; jahr?: string | string[] }> }) {
|
||||
const principal = await requireEditorial();
|
||||
const rawSearchParams = await searchParams;
|
||||
const query = normalizedQuery(singleValue(rawSearchParams.suche));
|
||||
const format = singleValue(rawSearchParams.format);
|
||||
const jahr = singleValue(rawSearchParams.jahr);
|
||||
|
||||
if (query) {
|
||||
const results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
|
||||
description: query,
|
||||
page: singleValue(rawSearchParams.page),
|
||||
});
|
||||
|
||||
if (format || jahr) {
|
||||
results.items = results.items.filter(asset => {
|
||||
let matches = true;
|
||||
|
||||
if (format) {
|
||||
const width = asset.exifInfo?.exifImageWidth ?? 0;
|
||||
const height = asset.exifInfo?.exifImageHeight ?? 0;
|
||||
if (width > 0 && height > 0) {
|
||||
const isLandscape = width >= height;
|
||||
if (format === 'quer' && !isLandscape) matches = false;
|
||||
if (format === 'hoch' && isLandscape) matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jahr && matches) {
|
||||
const dateStr = asset.localDateTime ?? asset.fileCreatedAt;
|
||||
if (!dateStr || !dateStr.startsWith(jahr)) {
|
||||
matches = false;
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
});
|
||||
}
|
||||
|
||||
const downloadOptions = await loadEditorialDownloadOptions(
|
||||
principal.editorialId,
|
||||
results.items.map((asset) => asset.id),
|
||||
);
|
||||
const lightboxItems = await lightboxService.getLightboxItems(principal.editorialId);
|
||||
const lightboxAssetIds = new Set(lightboxItems.map(i => i.assetId));
|
||||
|
||||
return (
|
||||
<section className="editorial-section" aria-labelledby="albums-title">
|
||||
<p className="editorial-kicker">Bildarchiv · Suche</p>
|
||||
<div className="editorial-title-row">
|
||||
<h1 id="albums-title">Suchergebnisse</h1>
|
||||
</div>
|
||||
<GlobalSearchForm query={query} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<PhotoContactSheet
|
||||
albumName="Alle Alben"
|
||||
downloadOptions={downloadOptions}
|
||||
page={results}
|
||||
query={query}
|
||||
showAlbumName
|
||||
lightboxAssetIds={lightboxAssetIds}
|
||||
/>
|
||||
<GlobalSearchPagination page={results} query={query} />
|
||||
</section>
|
||||
@@ -52,7 +85,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
<h1 id="albums-title">Ihre Alben</h1>
|
||||
<p>Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen.</p>
|
||||
</div>
|
||||
<GlobalSearchForm query={query} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
{result.albums.length === 0 ? (
|
||||
<p className="catalog-empty">Für Ihre Redaktion sind noch keine Fotoalben freigegeben.</p>
|
||||
) : (
|
||||
@@ -62,17 +95,36 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
);
|
||||
}
|
||||
|
||||
function GlobalSearchForm({ query }: { query: string }) {
|
||||
function GlobalSearchForm({ query, format, jahr }: { query: string; format?: string; jahr?: string; }) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const years = Array.from({ length: 10 }, (_, i) => currentYear - i);
|
||||
|
||||
return (
|
||||
<form action="/redaktion/alben" className="global-search-form" role="search">
|
||||
<input
|
||||
type="search"
|
||||
name="suche"
|
||||
defaultValue={query}
|
||||
placeholder="Alle Alben durchsuchen..."
|
||||
aria-label="Alle Alben durchsuchen"
|
||||
/>
|
||||
<button type="submit">Suchen</button>
|
||||
<form action="/redaktion/alben" className="global-search-form flex flex-wrap gap-4 items-center mb-8 bg-gray-50 p-4 rounded-xl border border-gray-200" role="search">
|
||||
<div className="flex-grow">
|
||||
<input
|
||||
type="search"
|
||||
name="suche"
|
||||
defaultValue={query}
|
||||
placeholder="Alle Alben durchsuchen..."
|
||||
aria-label="Alle Alben durchsuchen"
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
<select name="format" defaultValue={format || ""} className="px-3 py-2 border border-gray-300 rounded-md">
|
||||
<option value="">Alle Formate</option>
|
||||
<option value="quer">Querformat</option>
|
||||
<option value="hoch">Hochformat</option>
|
||||
</select>
|
||||
<select name="jahr" defaultValue={jahr || ""} className="px-3 py-2 border border-gray-300 rounded-md">
|
||||
<option value="">Alle Jahre</option>
|
||||
{years.map(y => (
|
||||
<option key={y} value={y.toString()}>{y}</option>
|
||||
))}
|
||||
</select>
|
||||
<button type="submit">Suchen</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user