fix: harden production flows and user messaging
This commit is contained in:
1 parent
52dce168dd
commit
86dfe8053d
43 files changed
+3520
-358
No files matched your search
@@ -23,11 +23,19 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
const jahr = singleValue(rawSearchParams.jahr);
|
||||
|
||||
if (query) {
|
||||
const results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
|
||||
description: query,
|
||||
page: 1,
|
||||
size: SEARCH_FETCH_SIZE,
|
||||
});
|
||||
let results;
|
||||
try {
|
||||
results = await albumCatalog.searchVisiblePhotos(principal.editorialId, {
|
||||
description: query,
|
||||
page: 1,
|
||||
size: SEARCH_FETCH_SIZE,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "RATE_LIMITED") {
|
||||
return <SearchRateLimited query={query} format={format} jahr={jahr} />;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const filtered = filterPhotos(results.items, { format, jahr });
|
||||
const { result: page, currentPage } = paginatePhotos(filtered, singleValue(rawSearchParams.page), PHOTO_PAGE_SIZE);
|
||||
@@ -86,6 +94,18 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
);
|
||||
}
|
||||
|
||||
function SearchRateLimited({ query, format, jahr }: { query: string; format?: string; jahr?: string }) {
|
||||
return (
|
||||
<div className="space-y-6 max-w-7xl" aria-labelledby="albums-title">
|
||||
<PageHeader kicker="Bildarchiv · Suche" title="Bitte kurz warten" titleId="albums-title" />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<p className="bg-muted p-4 rounded-md" role="status">
|
||||
Es wurden sehr viele Suchanfragen gestellt. Bitte versuchen Sie es in Kürze erneut.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user