// app/notes/page.tsx // Server Component. Loads all notes from PocketBase and hands them to // the Client Component which owns the CRUD UI state. // // Notes live in the ysterbaard_notes collection. If the collection is // missing (PB returns 404) the page renders an actionable error so the // user knows to create it in the admin UI. import { fetchCollection } from "@/lib/pb"; import type { YsterbaardNote } from "@/lib/types"; import PageHeader from "@/components/PageHeader"; import NotesList from "./NotesList"; export const dynamic = "force-dynamic"; async function loadNotes(): Promise { try { const list = await fetchCollection("ysterbaard_notes", { page: 1, perPage: 500, sort: "-created", }); return list.items ?? []; } catch (err) { // Surface the failure to the client so the page can show guidance. const msg = err instanceof Error ? err.message : "Unknown PB error"; if (msg.includes("404") || msg.toLowerCase().includes("not found")) { throw new Error( "The ysterbaard_notes collection is missing on PocketBase. " + "Open https://pb.agent.apphub.co.za/_/ and create it before " + "using this tab. See docs/superpowers/specs/2026-09-16-notes-tab-design.md for the field spec.", ); } throw err; } } export default async function NotesPage() { const notes = await loadNotes(); return ( <> ); }