From c3c10229b04c26ea248b8098597a300c27224094 Mon Sep 17 00:00:00 2001 From: agent Date: Mon, 26 Oct 2026 11:19:54 +0000 Subject: [PATCH 1/5] Site design: separate booking page and basket page The header button, the basket indicator, the shop's "view basket" links, hero buttons and the payment return page all pointed at a hard-coded /book. Site design now has a Booking page (where the CTA leads) and a Basket page (where the basket leads; empty = the booking page), and warns when the page picked is unpublished or lacks its Shop / Checkout block. On a basket page of its own, an empty basket links to the booking page instead of saying "pick a service above". Sites saved before this keep their links: the booking page falls back to the CTA's old address, then /book. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW --- AGENTS.md | 1 + README.md | 2 +- app-admin/src/lib/admin/blockDefaults.ts | 2 +- .../src/lib/admin/editors/BlockEditor.svelte | 2 +- app-admin/src/routes/globals/+page.server.ts | 9 +++- app-admin/src/routes/globals/+page.svelte | 50 ++++++++++++++++--- app-public/src/lib/components/Header.svelte | 11 ++-- .../src/routes/checkout/return/+page.svelte | 8 +-- .../shared/src/blocks/CheckoutBlock.svelte | 11 +++- packages/shared/src/blocks/HeroBlock.svelte | 5 +- packages/shared/src/blocks/ShopBlock.svelte | 7 +-- packages/shared/src/types.ts | 25 ++++++++-- 12 files changed, 105 insertions(+), 28 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 62d1c71..e6c8baa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -154,6 +154,7 @@ 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`. - `+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 f0ba0af..7e361ab 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 a `checkout` block, and point the header CTA at it. +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.) ## Bundles and codes diff --git a/app-admin/src/lib/admin/blockDefaults.ts b/app-admin/src/lib/admin/blockDefaults.ts index 28fcf95..5b6f454 100644 --- a/app-admin/src/lib/admin/blockDefaults.ts +++ b/app-admin/src/lib/admin/blockDefaults.ts @@ -33,7 +33,7 @@ export function createBlock(type: BlockType): ContentBlock { heading: 'Holistic and Experiential Learning about Happiness', subheading: 'Individual sessions, workshops and events in Oslo', buttonLabel: 'BOOK NOW', - buttonUrl: '/book' + buttonUrl: '' }; break; case 'button': diff --git a/app-admin/src/lib/admin/editors/BlockEditor.svelte b/app-admin/src/lib/admin/editors/BlockEditor.svelte index e2e9ec2..406f58c 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 }), '/page or https://…')} + {@render field('Button URL', block.data.buttonUrl || '', (buttonUrl) => updateData({ buttonUrl }), 'Empty = the booking page')}
{: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 323fd33..d9af794 100644 --- a/app-admin/src/routes/globals/+page.server.ts +++ b/app-admin/src/routes/globals/+page.server.ts @@ -27,8 +27,13 @@ export const load: PageServerLoad = async ({ locals }) => { getGlobal(locals.pb, 'colors', defaultColors) ]); - // Fetch all pages for the home page selector - const pages = await locals.pb.collection('pages').getFullList({ sort: 'slug', fields: 'id,slug,title' }); + // All pages for the page selectors, with what the booking and basket + // settings need to warn about (unpublished, no Shop / 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 { header, footer, colors, pages }; }; diff --git a/app-admin/src/routes/globals/+page.svelte b/app-admin/src/routes/globals/+page.svelte index 3c5215a..5d7aca1 100644 --- a/app-admin/src/routes/globals/+page.svelte +++ b/app-admin/src/routes/globals/+page.svelte @@ -2,6 +2,7 @@ import { enhance } from '$app/forms'; import ImageUploader from '$lib/admin/editors/ImageUploader.svelte'; import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate'; + import { shopLinks } from '$lib/types'; import type { SubmitFunction } from '@sveltejs/kit'; let { data, form } = $props(); @@ -9,8 +10,11 @@ let footer = $state(structuredClone(data.footer.data)); let colors = $state(structuredClone(data.colors.data)); let saving = $state(''); - // Older records may predate the CTA button; the inputs below need an object. - header.ctaButton ??= { label: '', href: '' }; + // 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); + header.basketPage ??= ''; footer.privacyPage ??= ''; function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; } @@ -34,6 +38,24 @@ { key: 'accent', label: 'Accent', hint: 'Highlights' } ]; + 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); + 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.'; + return ''; + } + const isHex = (value: unknown) => typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value); const submit: SubmitFunction = ({ formData }) => { @@ -86,10 +108,26 @@ {/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

+ +

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

+ {#if basketProblem(header.basketPage)}

⚠ {basketProblem(header.basketPage)}

{/if}

Home page