fix(ui/books): guard against null items from PocketBase listAll

This commit is contained in:
Admin
2026-03-04 00:46:40 +05:00
parent f6febfdb5e
commit 89ff90629f
2 changed files with 3 additions and 3 deletions

View File

@@ -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> {

View File

@@ -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>