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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
This commit is contained in:
agent 2026-10-26 11:19:54 +00:00
parent 76b297153e
commit c3c10229b0
12 changed files with 105 additions and 28 deletions

View file

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

View file

@ -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}
<button class="btn btn-sm mt-1" type="button" onclick={addHeaderLink}>Add link</button>
<h3 class="mt-6 mb-2 font-bold">CTA button</h3>
<div class="grid grid-cols-2 gap-2">
<input class="input w-full" aria-label="Button label" bind:value={header.ctaButton.label} placeholder="Label" />
<input class="input w-full" aria-label="Button address" bind:value={header.ctaButton.href} placeholder="/book" />
</div>
<input class="input w-full" aria-label="Button label" bind:value={header.ctaButton.label} placeholder="Book Now" />
<p class="mt-1 text-sm text-base-content/60">Leads to the booking page. Empty = no button.</p>
<h3 class="mt-6 mb-2 font-bold">Booking page</h3>
<select class="select w-full" aria-label="Booking page" bind:value={header.bookingPage}>
{#if !pageBySlug(header.bookingPage)}<option value={header.bookingPage}>— Select a page —</option>{/if}
{#each data.pages as page (page.id)}
<option value={page.slug}>{page.title} [{page.slug}]</option>
{/each}
</select>
<p class="mt-1 text-sm text-base-content/60">Where people choose what to book: the header button, hero buttons without an address and “Book another” after paying lead here.</p>
{#if bookingProblem(header.bookingPage)}<p class="mt-1 text-sm font-semibold">⚠ {bookingProblem(header.bookingPage)}</p>{/if}
<h3 class="mt-6 mb-2 font-bold">Basket page</h3>
<select class="select w-full" aria-label="Basket page" bind:value={header.basketPage}>
<option value="">— Same as the booking page —</option>
{#each data.pages as page (page.id)}
<option value={page.slug}>{page.title} [{page.slug}]</option>
{/each}
</select>
<p class="mt-1 text-sm text-base-content/60">Where people pay: the basket in the header and “view basket” in the shop lead here.</p>
{#if basketProblem(header.basketPage)}<p class="mt-1 text-sm font-semibold">⚠ {basketProblem(header.basketPage)}</p>{/if}
<h3 class="mt-6 mb-2 font-bold">Home page</h3>
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
<option value="">— Select a page —</option>