fix(ui/books): guard null book fields in template; log null titles from PocketBase

This commit is contained in:
Admin
2026-03-04 00:49:50 +05:00
parent 89ff90629f
commit 353d7397eb
2 changed files with 9 additions and 3 deletions

View File

@@ -139,7 +139,13 @@ async function listOne<T>(collection: string, filter: string): Promise<T | null>
// ─── Books ────────────────────────────────────────────────────────────────────
export async function listBooks(): Promise<Book[]> {
return listAll<Book>('books', '', '+title');
const books = await listAll<Book>('books', '', '+title');
const nullTitles = books.filter((b) => b.title == null).length;
if (nullTitles > 0) {
log.warn('pocketbase', 'listBooks: books with null title', { count: nullTitles, total: books.length });
}
log.debug('pocketbase', 'listBooks', { total: books.length, nullTitles });
return books;
}
export async function getBook(slug: string): Promise<Book | null> {

View File

@@ -58,10 +58,10 @@
<!-- Info -->
<div class="p-2 flex flex-col gap-1 flex-1">
<h2 class="text-xs font-semibold text-zinc-100 line-clamp-2 leading-snug">
{book.title}
{book.title ?? ''}
</h2>
{#if book.author}
<p class="text-xs text-zinc-400 truncate">{book.author}</p>
<p class="text-xs text-zinc-400 truncate">{book.author ?? ''}</p>
{/if}
<div class="mt-auto pt-1 flex items-center justify-between gap-1">