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

@ -3,7 +3,7 @@
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, type BasketLine, type CheckoutBlockData } from '$shared/types';
import { DEFAULT_NOTES_HINT, DEFAULT_PRIVACY_NOTICE, shopLinks, type BasketLine, type CheckoutBlockData } from '$shared/types';
import { getBasketContext } from '$shared/basket.svelte';
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
import { formatDuration } from '$shared/items';
@ -15,6 +15,9 @@
const basket = getBasketContext();
// Not set in the admin preview, which has no footer data.
const privacyPage = $derived(page.data.footer?.privacyPage || '');
// On its own basket page there is no shop above, so point to the booking page.
const bookingHref = $derived(shopLinks(page.data.header).booking);
const shopAbove = $derived(page.url.pathname === bookingHref);
const customer = $state({ name: '', email: '', phone: '', notes: '' });
let payState = $state<'idle' | 'creating' | 'ready' | 'confirming' | 'error'>('idle');
@ -352,7 +355,11 @@
{#if basket.lines.length === 0}
<div class="mt-12 rounded-2xl border border-charcoal/10 bg-white/60 px-6 py-16 text-center">
<p class="font-serif text-xl">Your basket is empty</p>
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
{#if shopAbove}
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
{:else}
<a class="mt-6 inline-flex rounded-full bg-sage px-6 py-2.5 text-sm font-medium text-primary-content transition hover:bg-sage-dark" href={bookingHref}>Book a session</a>
{/if}
</div>
{:else}
{#if holdLeftMs !== null && slotLineCount}

View file

@ -1,4 +1,7 @@
<script lang="ts">
import { page } from '$app/state';
import { shopLinks } from '$shared/types';
let { data } = $props<{
data: {
heading?: string;
@ -21,7 +24,7 @@
{/if}
{#if data.buttonLabel}
<div class="animate-fade-in mt-10" style="animation-delay: 0.3s;">
<a class="btn rounded-full border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || '/book'}>
<a class="btn rounded-full border-0 bg-sage px-10 py-3 text-lg text-primary-content shadow-lg transition hover:bg-sage-dark hover:shadow-xl" href={data.buttonUrl || shopLinks(page.data.header).booking}>
{data.buttonLabel}
</a>
</div>

View file

@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/state';
import type { BasketLine, BookableTime, ShopBlockData, ItemRecord } from '$shared/types';
import { shopLinks, type BasketLine, type BookableTime, type ShopBlockData, type ItemRecord } from '$shared/types';
import { getBasketContext } from '$shared/basket.svelte';
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
import { bundleListPrice, formatDuration, lowestPrice } from '$shared/items';
@ -46,6 +46,7 @@
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
const basketHref = $derived(shopLinks(page.data.header).basket);
let visibleItems: ItemRecord[] = $derived.by(() => {
let result: ItemRecord[] = items;
@ -408,7 +409,7 @@
</button>
{#if itemInBasket}
<a
href="/book"
href={basketHref}
class="inline-flex items-center gap-1 text-sm font-medium text-sage-dark underline-offset-2 hover:underline"
>✓ In basket</a
>
@ -597,7 +598,7 @@
{#if ui.justAdded}
<p class="mt-3 text-sm font-medium text-sage-dark">
Added ✓ — <a href="/book" class="underline underline-offset-2 hover:no-underline">view basket</a>
Added ✓ — <a href={basketHref} class="underline underline-offset-2 hover:no-underline">view basket</a>
</p>
{/if}
</div>

View file

@ -61,8 +61,13 @@ export type UpcomingCalendarBlockData = {
export type HeaderGlobal = {
logo: { url: string; alt: string };
navLinks: { label: string; href: string }[];
ctaButton: { label: string; href: string };
/** The header button. It leads to the booking page; `href` is only read on sites set up before there was one. */
ctaButton: { label: string; href?: string };
homePage: string;
/** Slug of the page with the Shop block: the header button, hero buttons without an address and "Book another" lead here. */
bookingPage?: string;
/** Slug of the page with the Checkout block: the basket in the header and "view basket" lead here ('' = the booking page). */
basketPage?: string;
};
export type FooterGlobal = {
@ -84,10 +89,24 @@ export const defaultHeader: HeaderGlobal = {
{ label: 'About', href: '/about' },
{ label: 'Services', href: '/services' }
],
ctaButton: { label: 'Book Now', href: '/book' },
homePage: 'home'
ctaButton: { label: 'Book Now' },
homePage: 'home',
bookingPage: 'book',
basketPage: ''
};
/**
* Addresses of the booking and basket pages. Sites set up before these
* settings existed sent everything to `/book` or the button's own address,
* so that is still where they lead until a page is picked in Site design.
*/
export function shopLinks(header?: Partial<HeaderGlobal> | null) {
const legacy = header?.ctaButton?.href?.match(/^\/([a-z0-9-]+)\/?$/)?.[1];
const booking = header?.bookingPage || legacy || 'book';
const basket = header?.basketPage || booking;
return { booking: `/${booking}`, basket: `/${basket}` };
}
export const defaultFooter: FooterGlobal = {
businessName: 'Eva Shafik Massage',
tagline: 'Warm, restorative massage therapy for everyday wellbeing.',