Optional basket page; Button blocks follow the site colour; Site design tidy-up #9
12 changed files with 105 additions and 28 deletions
|
|
@ -154,6 +154,7 @@ To add an email block type: add to `EmailBlockType` in `packages/shared/src/type
|
||||||
### Routing
|
### 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).
|
- **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.
|
- **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`
|
- `+page.server.ts` for home fetches `slug = "home" && published = true`
|
||||||
- `[slug]/+page.server.ts` fetches by dynamic slug
|
- `[slug]/+page.server.ts` fetches by dynamic slug
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ Setup:
|
||||||
```
|
```
|
||||||
Copy the printed `whsec_…` signing secret into `STRIPE_WEBHOOK_SECRET`.
|
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*).
|
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
|
## Bundles and codes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export function createBlock(type: BlockType): ContentBlock {
|
||||||
heading: 'Holistic and Experiential Learning about Happiness',
|
heading: 'Holistic and Experiential Learning about Happiness',
|
||||||
subheading: 'Individual sessions, workshops and events in Oslo',
|
subheading: 'Individual sessions, workshops and events in Oslo',
|
||||||
buttonLabel: 'BOOK NOW',
|
buttonLabel: 'BOOK NOW',
|
||||||
buttonUrl: '/book'
|
buttonUrl: ''
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 'button':
|
case 'button':
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@
|
||||||
{@render field('Subheading', block.data.subheading || '', (subheading) => updateData({ subheading }))}
|
{@render field('Subheading', block.data.subheading || '', (subheading) => updateData({ subheading }))}
|
||||||
<div class="grid gap-x-4 md:grid-cols-2">
|
<div class="grid gap-x-4 md:grid-cols-2">
|
||||||
{@render field('Button label', block.data.buttonLabel || '', (buttonLabel) => updateData({ buttonLabel }))}
|
{@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')}
|
||||||
</div>
|
</div>
|
||||||
{:else if block.type === 'button'}
|
{:else if block.type === 'button'}
|
||||||
<div class="grid gap-x-4 md:grid-cols-2">
|
<div class="grid gap-x-4 md:grid-cols-2">
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,13 @@ export const load: PageServerLoad = async ({ locals }) => {
|
||||||
getGlobal(locals.pb, 'colors', defaultColors)
|
getGlobal(locals.pb, 'colors', defaultColors)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Fetch all pages for the home page selector
|
// All pages for the page selectors, with what the booking and basket
|
||||||
const pages = await locals.pb.collection('pages').getFullList({ sort: 'slug', fields: 'id,slug,title' });
|
// 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 };
|
return { header, footer, colors, pages };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { enhance } from '$app/forms';
|
import { enhance } from '$app/forms';
|
||||||
import ImageUploader from '$lib/admin/editors/ImageUploader.svelte';
|
import ImageUploader from '$lib/admin/editors/ImageUploader.svelte';
|
||||||
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
|
||||||
|
import { shopLinks } from '$lib/types';
|
||||||
import type { SubmitFunction } from '@sveltejs/kit';
|
import type { SubmitFunction } from '@sveltejs/kit';
|
||||||
|
|
||||||
let { data, form } = $props();
|
let { data, form } = $props();
|
||||||
|
|
@ -9,8 +10,11 @@
|
||||||
let footer = $state(structuredClone(data.footer.data));
|
let footer = $state(structuredClone(data.footer.data));
|
||||||
let colors = $state(structuredClone(data.colors.data));
|
let colors = $state(structuredClone(data.colors.data));
|
||||||
let saving = $state('');
|
let saving = $state('');
|
||||||
// Older records may predate the CTA button; the inputs below need an object.
|
// Older records may predate the CTA button and the booking/basket pages;
|
||||||
header.ctaButton ??= { label: '', href: '' };
|
// 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 ??= '';
|
footer.privacyPage ??= '';
|
||||||
|
|
||||||
function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; }
|
function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; }
|
||||||
|
|
@ -34,6 +38,24 @@
|
||||||
{ key: 'accent', label: 'Accent', hint: 'Highlights' }
|
{ 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 isHex = (value: unknown) => typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value);
|
||||||
|
|
||||||
const submit: SubmitFunction = ({ formData }) => {
|
const submit: SubmitFunction = ({ formData }) => {
|
||||||
|
|
@ -86,10 +108,26 @@
|
||||||
{/each}
|
{/each}
|
||||||
<button class="btn btn-sm mt-1" type="button" onclick={addHeaderLink}>Add link</button>
|
<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>
|
<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="Book Now" />
|
||||||
<input class="input w-full" aria-label="Button label" bind:value={header.ctaButton.label} placeholder="Label" />
|
<p class="mt-1 text-sm text-base-content/60">Leads to the booking page. Empty = no button.</p>
|
||||||
<input class="input w-full" aria-label="Button address" bind:value={header.ctaButton.href} placeholder="/book" />
|
<h3 class="mt-6 mb-2 font-bold">Booking page</h3>
|
||||||
</div>
|
<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>
|
<h3 class="mt-6 mb-2 font-bold">Home page</h3>
|
||||||
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
|
<select class="select w-full" aria-label="Home page" bind:value={header.homePage}>
|
||||||
<option value="">— Select a page —</option>
|
<option value="">— Select a page —</option>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { afterNavigate } from '$app/navigation';
|
import { afterNavigate } from '$app/navigation';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import type { HeaderGlobal } from '$lib/types';
|
import { shopLinks, type HeaderGlobal } from '$lib/types';
|
||||||
import { getBasketContext } from '$lib/basket.svelte';
|
import { getBasketContext } from '$lib/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, formatPrice } from '$shared/calendar';
|
import { DEFAULT_CURRENCY, formatPrice } from '$shared/calendar';
|
||||||
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
const basket = getBasketContext();
|
const basket = getBasketContext();
|
||||||
let hasItems = $derived(basket.count > 0);
|
let hasItems = $derived(basket.count > 0);
|
||||||
|
let links = $derived(shopLinks(header));
|
||||||
|
|
||||||
// Phone menu: a native modal <dialog> sliding in from the right, so focus
|
// Phone menu: a native modal <dialog> sliding in from the right, so focus
|
||||||
// trapping, Escape and the inert page behind come from the browser.
|
// trapping, Escape and the inert page behind come from the browser.
|
||||||
|
|
@ -64,7 +65,7 @@
|
||||||
{#if hasItems}
|
{#if hasItems}
|
||||||
<a
|
<a
|
||||||
class="relative flex items-center gap-2 rounded-full border border-charcoal/10 px-3 py-2 text-sm font-semibold text-charcoal/80 transition hover:border-sage hover:text-sage-dark md:px-4"
|
class="relative flex items-center gap-2 rounded-full border border-charcoal/10 px-3 py-2 text-sm font-semibold text-charcoal/80 transition hover:border-sage hover:text-sage-dark md:px-4"
|
||||||
href="/book"
|
href={links.basket}
|
||||||
aria-label="View your basket ({basket.count})"
|
aria-label="View your basket ({basket.count})"
|
||||||
>
|
>
|
||||||
{@render basketIcon()}
|
{@render basketIcon()}
|
||||||
|
|
@ -73,7 +74,7 @@
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if header.ctaButton?.label}
|
{#if header.ctaButton?.label}
|
||||||
<a class="cta btn hidden rounded-full border-0 px-6 hover:opacity-90 md:inline-flex" href={header.ctaButton.href}>{header.ctaButton.label}</a>
|
<a class="cta btn hidden rounded-full border-0 px-6 hover:opacity-90 md:inline-flex" href={links.booking}>{header.ctaButton.label}</a>
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
class="grid h-10 w-10 place-items-center rounded-full text-charcoal/80 transition hover:bg-charcoal/5 md:hidden"
|
class="grid h-10 w-10 place-items-center rounded-full text-charcoal/80 transition hover:bg-charcoal/5 md:hidden"
|
||||||
|
|
@ -118,7 +119,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{#if hasItems}
|
{#if hasItems}
|
||||||
<a class="mx-1 mt-6 flex items-center gap-3 rounded-xl border border-charcoal/10 px-4 py-3 font-semibold text-charcoal/80 transition hover:border-sage" href="/book">
|
<a class="mx-1 mt-6 flex items-center gap-3 rounded-xl border border-charcoal/10 px-4 py-3 font-semibold text-charcoal/80 transition hover:border-sage" href={links.basket}>
|
||||||
{@render basketIcon()}
|
{@render basketIcon()}
|
||||||
<span class="flex-1">Basket ({basket.count})</span>
|
<span class="flex-1">Basket ({basket.count})</span>
|
||||||
<span class="text-charcoal/60">{formatTotal(basket.total)}</span>
|
<span class="text-charcoal/60">{formatTotal(basket.total)}</span>
|
||||||
|
|
@ -128,7 +129,7 @@
|
||||||
|
|
||||||
{#if header.ctaButton?.label}
|
{#if header.ctaButton?.label}
|
||||||
<div class="border-t border-charcoal/10 p-6">
|
<div class="border-t border-charcoal/10 p-6">
|
||||||
<a class="cta btn btn-block rounded-full border-0 hover:opacity-90" href={header.ctaButton.href}>{header.ctaButton.label}</a>
|
<a class="cta btn btn-block rounded-full border-0 hover:opacity-90" href={links.booking}>{header.ctaButton.label}</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { formatInstant, formatPrice } from '$shared/calendar';
|
import { formatInstant, formatPrice } from '$shared/calendar';
|
||||||
import { formatDuration } from '$shared/items';
|
import { formatDuration } from '$shared/items';
|
||||||
|
import { shopLinks } from '$lib/types';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
let links = $derived(shopLinks(data.header));
|
||||||
|
|
||||||
// "Friday 15 January, 10:00" in the studio's timezone.
|
// "Friday 15 January, 10:00" in the studio's timezone.
|
||||||
function formatSlotDate(iso?: string | null) {
|
function formatSlotDate(iso?: string | null) {
|
||||||
|
|
@ -68,7 +70,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">Book another</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Book another</a>
|
||||||
{:else if data.state === 'processing'}
|
{:else if data.state === 'processing'}
|
||||||
<h1 class="font-serif text-4xl">Processing your payment…</h1>
|
<h1 class="font-serif text-4xl">Processing your payment…</h1>
|
||||||
<p class="mt-3 text-charcoal/70">
|
<p class="mt-3 text-charcoal/70">
|
||||||
|
|
@ -80,10 +82,10 @@
|
||||||
{:else if data.state === 'canceled' || data.state === 'failed'}
|
{:else if data.state === 'canceled' || data.state === 'failed'}
|
||||||
<h1 class="font-serif text-4xl">Payment not completed</h1>
|
<h1 class="font-serif text-4xl">Payment not completed</h1>
|
||||||
<p class="mt-3 text-charcoal/70">Your payment didn't go through — no money was captured. Please try again.</p>
|
<p class="mt-3 text-charcoal/70">Your payment didn't go through — no money was captured. Please try again.</p>
|
||||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">Back to the shop</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.basket}>Back to your basket</a>
|
||||||
{:else}
|
{:else}
|
||||||
<h1 class="font-serif text-4xl">Nothing to see here</h1>
|
<h1 class="font-serif text-4xl">Nothing to see here</h1>
|
||||||
<p class="mt-3 text-charcoal/70">This link is missing a payment reference.</p>
|
<p class="mt-3 text-charcoal/70">This link is missing a payment reference.</p>
|
||||||
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href="/">Back to the shop</a>
|
<a class="btn mt-8 rounded-full border-0 px-8 text-primary-content" style="background-color: var(--color-primary, #8a9a7b);" href={links.booking}>Back to the shop</a>
|
||||||
{/if}
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { page } from '$app/state';
|
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 { getBasketContext } from '$shared/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
|
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, formatInstant, formatPrice } from '$shared/calendar';
|
||||||
import { formatDuration } from '$shared/items';
|
import { formatDuration } from '$shared/items';
|
||||||
|
|
@ -15,6 +15,9 @@
|
||||||
const basket = getBasketContext();
|
const basket = getBasketContext();
|
||||||
// Not set in the admin preview, which has no footer data.
|
// Not set in the admin preview, which has no footer data.
|
||||||
const privacyPage = $derived(page.data.footer?.privacyPage || '');
|
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: '' });
|
const customer = $state({ name: '', email: '', phone: '', notes: '' });
|
||||||
let payState = $state<'idle' | 'creating' | 'ready' | 'confirming' | 'error'>('idle');
|
let payState = $state<'idle' | 'creating' | 'ready' | 'confirming' | 'error'>('idle');
|
||||||
|
|
@ -352,7 +355,11 @@
|
||||||
{#if basket.lines.length === 0}
|
{#if basket.lines.length === 0}
|
||||||
<div class="mt-12 rounded-2xl border border-charcoal/10 bg-white/60 px-6 py-16 text-center">
|
<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="font-serif text-xl">Your basket is empty</p>
|
||||||
|
{#if shopAbove}
|
||||||
<p class="mt-2 text-sm text-fg-body/70">Pick a service or product above.</p>
|
<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>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#if holdLeftMs !== null && slotLineCount}
|
{#if holdLeftMs !== null && slotLineCount}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { page } from '$app/state';
|
||||||
|
import { shopLinks } from '$shared/types';
|
||||||
|
|
||||||
let { data } = $props<{
|
let { data } = $props<{
|
||||||
data: {
|
data: {
|
||||||
heading?: string;
|
heading?: string;
|
||||||
|
|
@ -21,7 +24,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.buttonLabel}
|
{#if data.buttonLabel}
|
||||||
<div class="animate-fade-in mt-10" style="animation-delay: 0.3s;">
|
<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}
|
{data.buttonLabel}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state';
|
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 { getBasketContext } from '$shared/basket.svelte';
|
||||||
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
|
import { DEFAULT_CURRENCY, DEFAULT_TIMEZONE, addMonths, createCalendarMonth, formatInstant, formatPrice, startOfMonth, zonedDateKey, zonedInputToIso } from '$shared/calendar';
|
||||||
import { bundleListPrice, formatDuration, lowestPrice } from '$shared/items';
|
import { bundleListPrice, formatDuration, lowestPrice } from '$shared/items';
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
const weekdayLetters = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
|
||||||
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
const timezone = $derived<string>(page.data.timezone ?? DEFAULT_TIMEZONE);
|
||||||
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
|
const currency = $derived<string>(page.data.currency ?? DEFAULT_CURRENCY);
|
||||||
|
const basketHref = $derived(shopLinks(page.data.header).basket);
|
||||||
|
|
||||||
let visibleItems: ItemRecord[] = $derived.by(() => {
|
let visibleItems: ItemRecord[] = $derived.by(() => {
|
||||||
let result: ItemRecord[] = items;
|
let result: ItemRecord[] = items;
|
||||||
|
|
@ -408,7 +409,7 @@
|
||||||
</button>
|
</button>
|
||||||
{#if itemInBasket}
|
{#if itemInBasket}
|
||||||
<a
|
<a
|
||||||
href="/book"
|
href={basketHref}
|
||||||
class="inline-flex items-center gap-1 text-sm font-medium text-sage-dark underline-offset-2 hover:underline"
|
class="inline-flex items-center gap-1 text-sm font-medium text-sage-dark underline-offset-2 hover:underline"
|
||||||
>✓ In basket</a
|
>✓ In basket</a
|
||||||
>
|
>
|
||||||
|
|
@ -597,7 +598,7 @@
|
||||||
|
|
||||||
{#if ui.justAdded}
|
{#if ui.justAdded}
|
||||||
<p class="mt-3 text-sm font-medium text-sage-dark">
|
<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>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,13 @@ export type UpcomingCalendarBlockData = {
|
||||||
export type HeaderGlobal = {
|
export type HeaderGlobal = {
|
||||||
logo: { url: string; alt: string };
|
logo: { url: string; alt: string };
|
||||||
navLinks: { label: string; href: 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;
|
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 = {
|
export type FooterGlobal = {
|
||||||
|
|
@ -84,10 +89,24 @@ export const defaultHeader: HeaderGlobal = {
|
||||||
{ label: 'About', href: '/about' },
|
{ label: 'About', href: '/about' },
|
||||||
{ label: 'Services', href: '/services' }
|
{ label: 'Services', href: '/services' }
|
||||||
],
|
],
|
||||||
ctaButton: { label: 'Book Now', href: '/book' },
|
ctaButton: { label: 'Book Now' },
|
||||||
homePage: 'home'
|
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 = {
|
export const defaultFooter: FooterGlobal = {
|
||||||
businessName: 'Eva Shafik Massage',
|
businessName: 'Eva Shafik Massage',
|
||||||
tagline: 'Warm, restorative massage therapy for everyday wellbeing.',
|
tagline: 'Warm, restorative massage therapy for everyday wellbeing.',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue