diff --git a/AGENTS.md b/AGENTS.md index e6c8baa..f60585b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -154,7 +154,8 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type ### Routing - **Admin app** (`app-admin`): All routes except `/login` are auth-guarded in `hooks.server.ts` (which also refreshes the token per request and sets the cookie's `Secure` flag from the real scheme). The root layout renders the admin shell (grouped sidebar) except on `/login` and `/preview`. The `/preview` route reads `sessionStorage` set by the page editor (same-origin, so it works). - **Public app** (`app-public`): No auth guard. The root layout always renders Header/Footer. `+layout.server.ts` fetches header/footer/colors globals + basket/items/slots for every page. -- **Booking and basket pages** are picked in Site design (`header.bookingPage`, `header.basketPage`; '' = the booking page). Links to them come from `shopLinks(header)` in `packages/shared/src/types.ts` (blocks read `page.data.header`) — never hard-code `/book`. +- **Booking and basket links**: booking = the header CTA's address, basket = the optional basket page (`header.basketPage`; '' = the CTA's address), both from `shopLinks(header)` in `packages/shared/src/types.ts` (blocks read `page.data.header`) — never hard-code `/book`. +- **Class names in components are written out whole** (`'btn-primary'`, not `` `btn-${variant}` ``): Tailwind only generates classes it finds in the source, so a built-up name silently gets no style. - `+page.server.ts` for home fetches `slug = "home" && published = true` - `[slug]/+page.server.ts` fetches by dynamic slug diff --git a/README.md b/README.md index 7e361ab..9131082 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ Setup: ``` Copy the printed `whsec_…` signing secret into `STRIPE_WEBHOOK_SECRET`. 4. Import the updated `pb_schema.json` (adds `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`). Two visitors can't take the same place: holds are checked and written in one PocketBase transaction (see *Slot availability*). -5. Create a published page (e.g. slug `book`) with a `shop` block, and pick it as *Site design → Header → Booking page*: the header button, hero buttons without an address and *Book another* after paying lead there. Add a `checkout` block either to the same page, or to a page of its own picked as *Basket page*: the basket in the header and *view basket* in the shop lead there. Site design warns when the page picked lacks the block it needs or isn't published. (Sites set up before these settings keep using the header button's old address, or `/book`, until a page is picked.) +5. Create a published page (e.g. slug `book`) with a `shop` block and point the header CTA at it (*Site design → Header*); hero buttons without an address and *Book another* after paying lead there too. Put a `checkout` block on the same page, or on a page of its own picked as the optional *Basket page*: the basket in the header and *view basket* in the shop lead there (empty = the CTA's address). Site design warns when the basket's page isn't published or has no `checkout` block. ## Bundles and codes diff --git a/app-admin/src/lib/admin/editors/BlockEditor.svelte b/app-admin/src/lib/admin/editors/BlockEditor.svelte index 406f58c..cb756f7 100644 --- a/app-admin/src/lib/admin/editors/BlockEditor.svelte +++ b/app-admin/src/lib/admin/editors/BlockEditor.svelte @@ -101,7 +101,7 @@ {@render field('Subheading', block.data.subheading || '', (subheading) => updateData({ subheading }))}
{@render field('Button label', block.data.buttonLabel || '', (buttonLabel) => updateData({ buttonLabel }))} - {@render field('Button URL', block.data.buttonUrl || '', (buttonUrl) => updateData({ buttonUrl }), 'Empty = the booking page')} + {@render field('Button URL', block.data.buttonUrl || '', (buttonUrl) => updateData({ buttonUrl }), 'Empty = the CTA button’s address')}
{:else if block.type === 'button'}
diff --git a/app-admin/src/routes/globals/+page.server.ts b/app-admin/src/routes/globals/+page.server.ts index d9af794..411bf71 100644 --- a/app-admin/src/routes/globals/+page.server.ts +++ b/app-admin/src/routes/globals/+page.server.ts @@ -27,12 +27,12 @@ export const load: PageServerLoad = async ({ locals }) => { getGlobal(locals.pb, 'colors', defaultColors) ]); - // All pages for the page selectors, with what the booking and basket - // settings need to warn about (unpublished, no Shop / Checkout block). + // All pages for the page selectors, with what the basket setting warns + // about (unpublished, no Checkout block). const records = await locals.pb.collection('pages').getFullList({ sort: 'slug', fields: 'id,slug,title,published,blocks' }); const pages = records.map((page) => { const types = new Set(((page.blocks as { type?: string }[]) || []).map((block) => block.type)); - return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasShop: types.has('shop'), hasCheckout: types.has('checkout') }; + return { id: page.id, slug: page.slug, title: page.title, published: !!page.published, hasCheckout: types.has('checkout') }; }); return { header, footer, colors, pages }; diff --git a/app-admin/src/routes/globals/+page.svelte b/app-admin/src/routes/globals/+page.svelte index 5d7aca1..1d5938a 100644 --- a/app-admin/src/routes/globals/+page.svelte +++ b/app-admin/src/routes/globals/+page.svelte @@ -10,10 +10,8 @@ let footer = $state(structuredClone(data.footer.data)); let colors = $state(structuredClone(data.colors.data)); let saving = $state(''); - // Older records may predate the CTA button and the booking/basket pages; - // they start from wherever the site's links led until now. - header.ctaButton ??= { label: '' }; - header.bookingPage ||= shopLinks(header).booking.slice(1); + // Older records may predate the CTA button and the basket page; the inputs below need values. + header.ctaButton ??= { label: '', href: '' }; header.basketPage ??= ''; footer.privacyPage ??= ''; @@ -40,19 +38,12 @@ const pageBySlug = (slug: string) => data.pages.find((page) => page.slug === slug); - function bookingProblem(slug: string) { - const page = pageBySlug(slug); - if (!page) return `There is no page “${slug}” — pick one.`; - if (!page.published) return 'This page isn’t published yet.'; - if (!page.hasShop) return 'This page has no Shop block.'; - return ''; - } - - function basketProblem(slug: string) { - const page = pageBySlug(slug || header.bookingPage); + // The page the basket links lead to: the basket page, else the CTA's address when that is a page here. + function basketProblem() { + const page = pageBySlug(shopLinks(header).basket.replace(/^\/|\/$/g, '')); if (!page) return ''; - if (!page.published) return 'This page isn’t published yet.'; - if (!page.hasCheckout) return 'This page has no Checkout block, so people can’t pay from it.'; + if (!page.published) return `“${page.title}” isn’t published yet.`; + if (!page.hasCheckout) return `“${page.title}” has no Checkout block, so people can’t pay from it.`; return ''; } @@ -108,26 +99,20 @@ {/each}

CTA button

- -

Leads to the booking page. Empty = no button.

-

Booking page

- -

Where people choose what to book: the header button, hero buttons without an address and “Book another” after paying lead here.

- {#if bookingProblem(header.bookingPage)}

⚠ {bookingProblem(header.bookingPage)}

{/if} -

Basket page

+
+ + +
+

Hero buttons without an address and “Book another” after paying lead here too.

+

Basket page (optional)

-

Where people pay: the basket in the header and “view basket” in the shop lead here.

- {#if basketProblem(header.basketPage)}

⚠ {basketProblem(header.basketPage)}

{/if} +

Where people pay: the basket in the header and “view basket” in the shop lead here. Leave it empty if the CTA button’s page has the Checkout block.

+ {#if basketProblem()}

⚠ {basketProblem()}

{/if}

Home page