fix(ui/books): guard against null items from PocketBase listAll
This commit is contained in:
@@ -125,7 +125,7 @@ async function listAll<T>(collection: string, filter = '', sort = ''): Promise<T
|
|||||||
const data = await pbGet<PBList<T>>(
|
const data = await pbGet<PBList<T>>(
|
||||||
`/api/collections/${collection}/records?${params.toString()}`
|
`/api/collections/${collection}/records?${params.toString()}`
|
||||||
);
|
);
|
||||||
return data.items;
|
return data.items ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listOne<T>(collection: string, filter: string): Promise<T | null> {
|
async function listOne<T>(collection: string, filter: string): Promise<T | null> {
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
<div class="mb-6">
|
<div class="mb-6">
|
||||||
<h1 class="text-2xl font-bold text-zinc-100">Library</h1>
|
<h1 class="text-2xl font-bold text-zinc-100">Library</h1>
|
||||||
<p class="text-zinc-400 text-sm mt-1">{data.books.length} books</p>
|
<p class="text-zinc-400 text-sm mt-1">{data.books?.length ?? 0} books</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if data.books.length === 0}
|
{#if !data.books?.length}
|
||||||
<div class="text-center py-20 text-zinc-500">
|
<div class="text-center py-20 text-zinc-500">
|
||||||
<p class="text-lg">No books scraped yet.</p>
|
<p class="text-lg">No books scraped yet.</p>
|
||||||
<p class="text-sm mt-2">Use the scraper API to add books.</p>
|
<p class="text-sm mt-2">Use the scraper API to add books.</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user